Moving a git repository

Portaljacker picture Portaljacker · Oct 31, 2011 · Viewed 48k times · Source

This question may be dumb, but I've been wondering it for a while. It's about git repositories, but I assume it's the same for local repositories for other DVCS'.

Lets say my project is like this when it starts:

  • Project
    • .git
    • all the other folders in the project

So that's how it would work when you set it up right?

Lets say I move the Project folder somewhere else, would I have to change anything? Or is all the repository stuff in the .git folder relative only to the Project folder ignoring the whole file tree above Project.

I'm pretty sure moving Project wouldn't matter but I just wanted to make sure.

Answer

Brent Baccala picture Brent Baccala · Jul 2, 2012

I've found that submodules are not relative in git.

So, if you want to move a project that contains submodules, you have to edit the .git file in the submodule, as well as the "worktree" attribute in the submodule config file, which is stored in the parent's .git/modules/MODULENAME/config file.