Moving history between git reposApril 3, 2009 7:28 pm General
So GLib and GTK+ have officially moved from svn to git this week. I had been doing some work in my own git repos, but they were based on various git-svn checkouts and they were all hashed differently, so it wasn’t possible to just merge from one of them into the new official git repos.
It turns out that it’s quite easy to merge your history over, though. Here’s what I did.
Say there is an old git repo with a branch called new-awesome-stuff. You want to create a branch in the new git repo with the same name, and merge the history over.
(in the old repo)
git checkout new-awesome-stuff
git format-patch master
This generates patches for each revision.. say there were 34 revisions in this branch. You’ll get 34 patch files whose names begin with 00nn (where nn is 01..34).
(in the new repo)
git checkout -b new-awesome-stuff
git am 00*.patch
If you’re putting things on github as I am, this should help you maintain your work in a single repo instead of having four different repos for the same project as I had.