Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if a commit is cherry-picked in?

Tags:

git

Is there a way to determine if a commit is cherry-picked in and which origin commit the changes cherry-picked from?

git cherry-pick -x is a solution to record the information when I do the cherry-pick. But if we didn't use the -x option, are there any other solutions?

like image 383
atiking Avatar asked Sep 26 '14 04:09

atiking


People also ask

Does git cherry pick commit?

git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. 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.

How do you commit cherry pick changes?

git cherry-pick -n <commit> # get your patch, but don't commit (-n = --no-commit) git reset # unstage the changes from the cherry-picked commit git add -p # make all your choices (add the changes you do want) git commit # make the commit!

Does cherry pick USE SAME commit ID?

Even if you edit a cherry-picked commit so that the tree, the commit message, the author and committer information are exactly the same, the SHA of the parent commit (or commits, if dealing with merge commits) will be always different.

How do you get commit hash for cherry pick?

Go to either the git log or the GitHub UI and grab the unique commit hashes for each of the commits that you want. “Cherry pick” the commits you want into this branch. Run this command: git cherry-pick super-long-hash-here . That will pull just this commit into your current branch.


1 Answers

Git provides

git cherry

git log --cherry

both of which at a low level use git patch-id to determine when it thinks changes have been cherry picked. Those commands will virtually never have false positives, but they may have false negatives.

like image 159
Andrew C Avatar answered Oct 21 '22 13:10

Andrew C