git cherry-pick recommendations

If you’re planning to cherry-pick commits between branches, I recommend that you always use the -xflag when cherry picking:

““
Quote
-x

When recording the commit, append a line that says “(cherry picked from commit …)”to the original commit message in order to indicate which commit this change was cherry-picked from.
This is done only for cherry picks without conflicts. Do not use this option if you are cherry-picking from your private branch because the information is useless to the recipient. If on the other hand you are cherry-picking between two publicly visible branches (e.g. backporting a fix to a maintenance branch for an older release from a development branch), adding this information can be useful.

Cherry-picking can quickly complicate a source tree, so having the extra information available will help provide a reference when issues arise.

It’s important to note that cherry-picking makes merging and rebasing difficult if done without careful thought – you can create false conflicts and must now manually resolve empty changes. When we know which commits were cherry-picks, we can pre-plan which commits to explicitly skip merging or rebasing.

Alternatively, try to only cherry-pick changes to/from branches that will not be merged back into trunk!

Further Reading

For more info on how to skip individual commits while merging branches, please see this stack overflow article

Share Your Thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.