Ubuntu Linux Resource: Install and Use Ubuntu!

Sebastian Kügler: Merging branches upstream with Git.

This is one of those “I write it on my blog so I can easily find it
back

posts, that’s hopefully useful to someone out there.
For KDE development, I’m using git and git-svn to manage the codebase.
Earlier today, I’ve merged a branch I had created over new year’s holiday. It
consisted of 25 patches, some larger (implementing a new feature), some smaller,
cleanups, but also some patches I wanted to keep separate for easier reference
and review. I didn’t want to commit it to KDE’s SVN as one huge commit, but also
not as 25, with a lot of those smaller ones that were more the “savegame” type
of commit you do once in a while to easily get back to a “working state” when
you’re about to break things or experiment.
Git’s rebase tool is what I wanted then. I’ve started off with my branch,
counted it was 25 commits I want to restructure.

git rebase --interactive HEAD~25

Gives you a list you can pick commits from. Every commit is shown on one
line, starting with the keyword “pick”. For commits you want to keep as-is,
leave that line alone. Make it “squash” to combine this commit with the one on
the previous line. Write “edit” to tweak the commit message. Just remove the
commits you don’t want. Git will instruct you to do what’s needed, changing a
log message, possibly solving a conflict. You pick up the rebasing process with

git rebase --continue

then. If you’re done, you can merge your branch, for example using “git svn
dcommit” (do check with “git log”, “git show” and “git svn dcommit -n” first if
everything worked OK).


You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

AddThis Social Bookmark Button

Leave a Reply

You must be logged in to post a comment.