Can we know any git commit is from cherry-pick, and from which commit?
Asked
Active
Viewed 399 times
1
-
No, you can't know that. Unless someone explicitly indicates the source of the commit in the commit message, there's no metadata that tells you "this commit originated as a cherry pick of another commit". – larsks May 29 '20 at 02:41
2 Answers
0
As I look in git source, there is no differences in commit itself. You could check differences in all commits and check how many changes is same, but it is slow and not guarantee all results (cherry pick could be merged, not fast forward). Another solution is referencing by commit message when cherry picking. In most cases you have same commit message, so you can check by this.

Leszek Mazur
- 2,443
- 1
- 14
- 28
0
Consider using git cherry-pick -x
when cherry picking. It will add a line to the commit message saying which commit you cherry picked from.
https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x

Stig Rohde Døssing
- 3,621
- 2
- 7
- 7