Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving a git repository down a hierarchy level

I was searching for hours now but couldn't find a satisfying answere even though it appears to be simple noobish question. What I basically want to accomplish is to move my .git directory which currently resides besides my project folder down into the project folder. Optimally this shouldn't alter the repository history at all although I don't know whether this is actually possible. The reason I want to do this a somewhat IDE/project-type related problem I can solve this way.

I appreciate any help, thanks.

like image 554
user1846302 Avatar asked Nov 23 '12 00:11

user1846302


People also ask

How do I transfer a repository?

Mirroring a repositoryOpen Terminal . Create a bare clone of the repository. Mirror-push to the new repository. Remove the temporary local repository you created earlier.


2 Answers

Sure just move it, then do a

git add -A
git commit -m "moved project"

in the new root. It won't be a big change in terms of data. It's just going to change the current commit's tree. All objects already exist.

like image 154
Adam Dymitruk Avatar answered Sep 21 '22 22:09

Adam Dymitruk


If you want your git repository to be changed so that it always looked like your files were located in the new path, you could re-write history similar to this

Otherwise, Adam's answer is what you want.

EDIT: Note that you should NOT use this if you or anyone else may be already using this repository as a submodule or a subtree anywhere.

like image 40
Carl Avatar answered Sep 21 '22 22:09

Carl