Reputation: 34079
My local git repository looks like this
C:\MyRepo
\MyProject
\.git
\ProjectFolder1
\ProjectFolder2
\ProjectFolder3
Now I want to add few folders which needs to be directly under "MyRepo" and needs to be part of same repository. I guess that means .git folder should also go directly under "MyRepo"
C:\MyRepo
\.git
\NewFolder1
\NewFolder2
\MyProject
\ProjectFolder1
\ProjectFolder2
\ProjectFolder3
How do I move the .git folder up a level without losing the history?
I'm using Windows OS and git version is 2.6.3.windows.1
Upvotes: 7
Views: 3220
Reputation: 2346
The important bit to consider is that the name of the parent folder of a repo is irrelevant to the repo.
Upvotes: 0
Reputation: 7184
You can move all your files to an inner MyProject
folder before moving the git repo. Something like this might work:
cd C:\MyRepo\MyProject
mkdir MyProject
git mv -k * MyProject
git commit
move .git ..
cd MyProject
move * ..
cd ..
rmdir MyProject
cd ..
git add NewFolder1 NewFolder2
git commit
See also How to import existing Git repository into another?
Upvotes: 6