Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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?

like image 763
Ben Hymers Avatar asked Nov 18 '09 14:11

Ben Hymers


3 Answers

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.

like image 186
rfunduk Avatar answered Nov 13 '22 09:11

rfunduk


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
like image 1
Jakub Narębski Avatar answered Nov 13 '22 09:11

Jakub Narębski


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'
like image 1
wereHamster Avatar answered Nov 13 '22 08:11

wereHamster