There are a couple of ways to move a local repository to a new location:
- Using simple copy-paste
This won't hurt you since, as long as you copy your .git
folder properly. Git won't get confused if you move it to a new place since it has a "relative" notion of where the project is. However, in the unlikely event of you having git version 1.7.8 or 1.7.9
AND also have submodules in your project, then you should be careful with this method, as it may lead to problems. Read more about it here.
- Using
git clone --mirror
This is a more "git" way of doing things. As described in the documentation
--mirror
Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking
branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.
- Using
git bundle
This is another "git" way of doing this. This would produce a single file that you can later move to your new destination and apply it there. If in your case, you don't have a repo at the new destination, I suggest you follow the answer from VonC about moving everything with git bundle
.
You would want to do something like
$ git bundle create /tmp/foo master
$ git bundle create /tmp/foo-all --all
$ git bundle list-heads /tmp/foo
$ git bundle list-heads /tmp/foo-all
I think the easiest is to just copy-paste your project if you have easy access to the new location.