开发者

How would I expand the 'scope' of an existing git repository to a parent directory?

开发者 https://www.devze.com 2022-12-11 15:16 出处:网络
I have a git repository in a directory a/b/, and I want to expand this so changes to a/ and subdirectories are stored too. Is开发者_高级运维 there any way to do this simply?Move b to somewhere new, ma

I have a git repository in a directory a/b/, and I want to expand this so changes to a/ and subdirectories are stored too. Is开发者_高级运维 there any way to do this simply?


Move b to somewhere new, make a new directory in it called b and git mv the contents into it. Now cp the stuff from a (excluding the original b of course) into here and git add them.


Try this, starting from to dir of the git repository:

$ mkdir b
$ git mv * b/
$ git commit  # describe that contents have moved
$ cd ..
$ mv b/* .
$ rmdir b


Just move the .git directory one level up and git add -A all files. For git it will look as if the existing files moved to a subdirectory and some new files appeared.

cd a/b
mv .git ../
cd ..
git add -A .
git commit -m 'Move git directory one level up'
0

精彩评论

暂无评论...
验证码 换一张
取 消