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
The short answer is NO. It is not possible to rename a file in Git and remember the history.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With