Sat, 25 Sep 2010

Splitting a git repository


Keywords: git directory subdirectory separate detach filter-branch

I had a bunch of directories in a single git repository and I wanted to make each one into its own repository. It turns out to be fairly simple. Suppose that the original repository is called orig and the directories in it are called dir1, dir2 etc. For each directory:

$ git clone --no-hardlinks orig dir1
$ cd dir1
$ git filter-branch --subdirectory-filter dir1 HEAD -- --all
$ git remote rm origin
$ rm -r .git/refs/original/
$ git reflog expire --expire=now --all
$ git gc --aggressive
$ git prune
$ du -sh *
$ git log

[/revision_control] permanent link




September 2017
Sun Mon Tue Wed Thu Fri Sat