I have an existing git repository:
my-repo/
.git/
foo/
foo-content-goes-here
bar/
bar-content-goes-here
I wish to get the following repository structures:
my-foo-repo/
.git/
foo-content-goes-here
my-bar-repo/
.git
bar-content-goes-here
I've looked at Detach (move) subdirectory into separate Git repository. This almost does what I need.
I ran these commands:
$ cd path/to/my-repo/../
$ git clone --no-hardlinks my-repo foo-repo
$ cd foo-repo
$ git remote rm origin
$ git filter-branch --tag-name-filter cat --subdirectory-filter foo \
--prune-empty -- --all
$ git reset --hard
$ git gc --aggressive
$ git prune
I say this almost works. Issues noted:
- The
git gc --aggressive
step takes over 2 hours for my repository. I have 13 repositories that need extracting from my current single repository. I can script this process, but would appreciate input into any ways to speed it up? git log
andgitk
show me the expected commits for the new foo-repo. gitX shows me the expected commits, plus a disconnected tree with the old history. The foo-repo directory size is much larger than I would expect, so presumably I have some stuff left over which needs cleaning up. I'm not sure how to get rid of this stuff? Do I even need to get rid of it prior to pushing?