Lately, I’ve been merging more and more commits between branches using git cherry-pick instead of a regular merge. Sometimes this is necessary because “the other guy” messes up his own branch and merging is just not feasible and sometimes it is useful because only some changes are of particular interest.
The workflow usually looks like this: First, I checkout the branch where the
merge should happen. Then, I will have a look at the branch using
from where I want to pick commits. Eventually, I cherry pick the commits by
specifying their hashes:
git cherry-pick ae4971b fe0281b
The last step is tedious and error-prone when typing the hashes by hand, so I wrote a stupid tool called pick-from to simplify this. After specifying from which branch to pick from
$ pick-from other-branch
pick-from shows me a list of commits that exist in the other branch but not in the current one:
Choose commits to cherry-pick and accept with `q' [ ] 13579ef: A commit message [X] fa45678: Another commit message
After selecting all desired commits with Enter and accepting with
q, the commit hashes are passed unconditionally to
[master fa45678] Another commit message Author: Gandalf the Grey [email@example.com] 1 file changed, 16 insertions(+), 7 deletions(-)
pick-from is written using the TUI toolkit urwid, which is practically
available for all distributions. If you want to let the tool look more
“officially” integrated, you can also alias it in your
[alias] pick-from = !pick-from
Have fun with that.
Post a comment
This post might also have some comments at Google+.