Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving a git repository

Tags:

git

repository

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.

like image 889
Portaljacker Avatar asked Oct 31 '11 00:10

Portaljacker


People also ask

How do I transfer a repository to a new repo?

You first have to get the original Git repository on your machine. Then, go into the repository. Finally, use the --mirror flag to copy everything in your local Git repository into the new repo.

How do I move a branch to another repository?

Clone the original repository onto your computer, and pull down the branches you want to preserve. Reset the repo's remote URL. See the GitHub documentation for more information. Then push the branches with git push --all .


2 Answers

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.

like image 67
Brent Baccala Avatar answered Sep 23 '22 00:09

Brent Baccala


Yes, everything in .git is relative. If you have added the repository as a named remote to another repository, you would have to change the remote URL in that other repository, though.

like image 45
David Z Avatar answered Sep 21 '22 00:09

David Z