Last Updated: February 25, 2016
·
928
· olivergierke

Quickly backport fixes into bugfix branches

My bug fixing workflow usually is as follows:

  1. Fix bug in master, polish, test, etc.
  2. Lookup SHA1 of the commit
  3. Switch to bugfix branch
  4. Do git cherry-pick $SHA-1 to backport the issue

If you add the following aliases

last = !git log -n 1 --pretty=format:%H $1
cp-last = !git cherry-pick `git last $1`

This can be shortened to:

  1. Fix bug in master, polish, test, etc.
  2. git checkout $bugfixBranch
  3. git cp-last master

The last alias discovers the SHA-1 of the last commit of the given branch. cp-last uses this command to cherry pick this commit into the current branch.