How to split a repository in git

We've decided in Smoltland that having a git repo would be a better idea. We were using Mercurial up till now, but as git seems to be the more popular choice in Fedoraland, it seems like it would be a good decision. Mercurial is actually a great system, and there are many aspects about it that I like, but there are a few features I feel I would use in they were available. Also, since git is more popular, it's more likely that when we have questions, we'll get an answer rather than 'hmm.... that's funny, git does this differently'.

I also think it's a good idea to split up the client and the server into two separate repositories, and therefore decided to do a bit of experimenting.

The process of converting a repo from hg to git is well documented. It was simple, and I used the script here:

Splitting a repo was a bit harder though, but after some searching, I came across this link here:

I had to make a few changes though.

yankee@dao:~/Projekten/Python/Smolt$ git filter-branch --tree-filter 'rm -rf benchmarks database .hgtags .project .pydevproject .settings smoon' HEAD
Rewrite d644ecb4d74fc0ca3245239dae97f051f825fdb1 (668/668)
Ref 'refs/heads/master' was rewritten

These refs were rewritten:

yankee@dao:~/Projekten/Python/Smolt$ ls
benchmarks client database doc GPL README smoon TODO

yankee@dao:~/Projekten/Python/Smolt$ git reset --hard
HEAD is now at dc4a914... 2007-12-11 Piotr Drąg (via

yankee@dao:~/Projekten/Python/Smolt$ git gc --aggressive
Generating pack...
Done counting 3633 objects.
Deltifying 3633 objects...
100% (3633/3633) done
Writing 3633 objects...
100% (3633/3633) done
Total 3633 (delta 2463), reused 0 (delta 0)
Pack pack-79afd8906cd79a2c59c60cd152e71988d0384452 created.
Removing unused objects 100%...

yankee@dao:~/Projekten/Python/Smolt$ git prune

yankee@dao:~/Projekten/Python/Smolt$ ls -a
. .. client doc .git GPL .hg .hgignore .hgsigs README TODO


This had a few extra added benefits. I got rid of some cruft that happened to be sitting around. While rewriting a repository like this on a regular basis is not a good idea, there are a few times you need to do this. The documentation for git-filter-branch is also good for removing copyrighted files, and other nasty things, that you do not have the rights to distribute.

The end result is that I have a repo that is just the client.

UPDATE: I should mention, backup everything first! These changes are permanent to the working directory, and if you should decide you want to go back, you must make a backup. Remember, git does use hashes to identify updates, so if you need a particular version, save the hash. But that's just common git sense.