Changes between Version 13 and Version 14 of WorkingWithGit


Ignore:
Timestamp:
Aug 20, 2016, 9:29:42 PM (8 years ago)
Author:
neverpanic (Clemens Lang)
Comment:

Document cherry-picking.

Legend:

Unmodified
Added
Removed
Modified
  • WorkingWithGit

    v13 v14  
    8484
    8585Note that the push will fail if the remote repository has new changes. Contrary to Subversion, it does not matter whether your changes conflict with the remote ones. If this happens, you must update your local working copy as described in the [#updating section on fetch the latest changes] and re-try the push.
     86
     87=== Merge a single change from master into a release branch ===
     88The equivalent to Subversion's `svn merge -c <revision> .` is `git cherry-pick`. Use `git cherry-pick` to merge a single change from master into a release branch. To do this, look up the commit ID of the commit you want to pick:
     89{{{
     90git log
     91# copy the commit ID
     92}}}
     93Switch to the target branch of the cherry pick:
     94{{{
     95git checkout release_2_3
     96}}}
     97Cherry-pick the commit. It is good practice to pass `-x` to `git cherry-pick`, which will automatically add a "Cherry picked from commit <commmitID>" line to the commit message of your cherry pick. You will have the option to modify the commit message, e.g. to describe why the backport was necessary.
     98{{{
     99git cherry-pick -x <commitID>
     100}}}
     101Finally, push the new commit using
     102{{{
     103git push [origin <branchname>]
     104}}}
    86105
    87106