From: "Michael" <>
This may seem a little strange. I'd like to merge parts of one commit sequence into another.

Off of "master", I have a bunch of small sequences of 3-4 commits, generally. Each on their own branch.

I have "integrationTest", branched off master, that has each of these merged in.

From IntegrationTest, I have "throw-away".

Then, I have "WhyDoesItCrashP", off of master, merged into throw-away.

Eventually, at the end of "WhyDoesItCrashP", I have a bunch of debugging printf's, and ultimately the fairly small changes needed to make it work.

What is the easiest way to select only those few changes from WhyDoesItCrashP, and collect those into a separate branch? To clarify, I do not want a few intact commits, I want some hunks of diff and not most hunks.

One gui tool that allows this is the 'git gui', which allows particular chunks, hunks and single lines to be staged in preparation for a big commit.

I usually use it when I want to split up a commit as part of a rebase. I simply mark the commit as being for edit, and then when the rebase gets to the right point, I use the git gui to 'amend' the last commit, stage the initial hunks, commit, stage some more and commit, etc, until it's time to give the rebase --continue in the terminal window. Rinse and repeat.

Obviously in your situation you may need to 'set' up the commit stream to be in the right order, (I usually needed to rebase multiple times because I'd just do one or two things during each rebase sequence). After a few goes you get quite good at it. If I remember corectly you can also in some cases cherry pick useful commits as well during a rebase but I've not used that.

There is also a command line option for hunk selection etc, but I've never used it...
You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to