fbpx

Moving a Git Repo from WordPress Theme Directory to Root

I had a WordPress project where my Git repo sat at the theme directory level. I wanted to move the Git repository up into the WordPress root directory so I could use WP Engine’s Git Push feature.

My file system with repo at theme directory:

wordpress/wp-content/themes/<my-theme repo>

But I needed the repo at the WordPress root directory:

<wordpress repo>/wp-content/themes/my-theme

How to Move a Git Repo from Theme Directory to WordPress Root Directory

$ cd wp-content/themes/my-theme

$ mv .git ../../../

Then I used Sal Ferrarelo’s preferred .gitignore file to exclude all WordPress core files and include only my theme and custom plugin.

$ git add .

$ git commit -m “Moved all the things”

Many thanks to this StackOverflow answer.

6 thoughts on “Moving a Git Repo from WordPress Theme Directory to Root”

  1. Thanks for your post. I am versioning just my theme, so what is the version of .gitignore you would recommend?

    1. Lauren Pittenger

      Hi, Stan. Thanks for your comment.

      If your repo is at the theme level, I don’t usually ignore anything. If it’s at the root level, you can ignore everything except your theme. You can do that by adding this to the .gitignore file in the root of your WordPress install:


      # ignore everything except the theme
      /*
      !wp-content/themes/mytheme

      Let me know if you have other questions.

Leave a Comment

Your email address will not be published. Required fields are marked *

GOT A PROJECT? LET’S TALK!

Are you ready to get your work out to the world?