Change path of the repo - move into a subfolder

Hi everyone!
I made a mistake creating a repo in a wrong folder.
I created a wordpress project and I decided to create a repo of my custom theme but after some days of work (shame on me) I realised that the path of the repo is the entire project, including the wp-core files / wp-admin files. 
Now I'd like to move the repo parent folder / container to a subfolder of the current one.
Is there an easy way to do that?
That's my tree of the repo

  • WP entire folder (current path of the repo)
    • WP admin
    • WP includes
    • WP content (here I want the repo)
      • themes
      • plugins
      • etc...
    • etc... 

Hope everything is clear.
Can anyone have some ideas how to do that?
Thanks to everyone!

I'm using Sourcetree last version.

1 answer

1 vote

I think it all depends on whether you have committed changes into your repo for the current structure and whether you need to be keep that history?

Since the name of the local folder containing the repository is not a key bit of information (i.e. it just holds the .git folder and the working copy) you should just be able to copy all of your files and folders up one level, leaving the .git folder in place.... if that makes sense.

e.g. from 

  • Parent folder
    • WP entire folder (current path of the repo)
      • .git
      • WP admin
      • WP includes
      • WP content (here I want the repo)
        • themes
        • plugins
        • etc...
      • etc...

up to 

  • Parent/WP entire folder 
    • WP admin
    • WP includes
    • WP content 
      • .git
      • themes
      • plugins 
    • etc... 

when you come to commit the repo you will find all of the higher files/folders 'deleted' and the ones you want moved up a level

So essentially you just advice to move the git-related file (folder + hidden files) into the folder I want. Then it makes a check with the new folder and it will find that some files are missed and it will interpretate as deleted. 
For me I think is fine because I made changes only into the WP content folder and I'm still on the master brach so I don't think there will be problems.

Thanks for the reply,  I'll try asap.

I suspect the end result will actually be the same, but personally, I would actually have cloned the repo into a new clean folder with an extra parent level and then moved everything apart for the .git folder one folder higher.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,764 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you