Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge tracking for Git cherry picking?

For example, I have a dev branch and a stable branch.

In case I have cherry-picked several commit from dev to stable.

Is there any way to let Git aware of the cherry-picked commits, and avoid doubly-merging it if I later merge, rebase or cherry-pick an overlapped range, from dev back to stable? (for which is a basic merge tracking feature in SVN)

like image 770
Adrian Shum Avatar asked Sep 21 '10 03:09

Adrian Shum


People also ask

Does git cherry pick merge?

With the cherry-pick command, Git lets you incorporate selected individual commits from any branch into your current Git HEAD branch. When performing a git merge or git rebase , all the commits from a branch are combined. The cherry-pick command allows you to select individual commits for integration.

How do I request cherry pick merge?

You can cherry-pick merge requests from the same project, or forks of the same project, from the GitLab user interface: In the merge request's secondary menu, select Commits to display the commit details page. Select the Options dropdown and select Cherry-pick to show the cherry-pick modal.

What do I do after git cherry pick?

Cherry picking is the act of picking a commit from a branch and applying it to another. git cherry-pick can be useful for undoing changes. For example, say a commit is accidently made to the wrong branch. You can switch to the correct branch and cherry-pick the commit to where it should belong.


1 Answers

Also notable is that -x flag for cherry-pick adds the SHA of the original commit to the end of the commit message.

I like to add the abbreviated SHA to the end of the commit summary, too, to make it easier to associate the cherry-picked commit with the original when looking at the log. Indicating who did the cherry pick can be helpful too, with the -s signoff flag.

Example:

> git cherry-pick -sex 27d4985

#333: fixes all the things (27d4985)  - how it fixes all the things  (cherry picked from commit 27d49855238364d0184ad344884a366b5b16e)  Signed-off-by: Chuck Norris <[email protected]> 
like image 78
Araxia Avatar answered Sep 28 '22 05:09

Araxia