Skip to content

Backporting with git

Ian edited this page Oct 6, 2015 · 4 revisions

The easiest way to do a backport from master to a branch is:

$ git checkout 1.6 
  * (you might get a "warning: refname '1.6' is ambiguous", 
  * but this does not matter in this case, IMHO, 
  * as it complains about branch name being a number, I think)
$ git pull
$ git cherry-pick <masters commit number>
$ git push -u origin 1.6
$ git checkout master

The backport commit should be very clean, so nothing else is written to the branch, like comitted fixes and additional NEWS notes in one single commit.


Please note:

If using $ git checkout origin/branchname, you get into the 'detached HEAD' state mode, which needs you to merge with a temporary branch.

HOW TO GET OUT of 'detached HEAD' state mode:

git checkout -b temp
git checkout temp
git diff master temp
git diff origin/master temp
git branch -f master temp
git checkout master
git branch -d temp