1

I want to confirm whether SHA is cherry-picked or not before i cherry-pick into a repo, by anyone else? how to find out whether someone already cherry-picked a SHA or not?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
ravi khot
  • 11
  • 1
  • 2
  • 2
    Seems similar to http://stackoverflow.com/questions/2922652/git-is-there-a-way-to-figure-out-where-a-commit-was-cherry-picked-from – VonC Apr 02 '13 at 06:15

2 Answers2

4

If it was picked with

git cherry-pick -x <sha1>

then the commit message will contain the original commit ID ("(cherry picked from commit ...)"). So:

git log --grep <sha1>

will find it. Otherwise, git cherry will suggest commits that have not been picked into the current branch. To see if that commit is still a candidate for picking:

git cherry <upstream> | fgrep <sha1>

If you go ahead and try to pick again, in the absence of conflicts, running cherry-pick for a second time won't make any more changes. If there are conflicts, you'll need to check the logs for indications that it's already been applied.

Joe
  • 29,416
  • 12
  • 68
  • 88
0

THe SHA1 of a cherry-picked commit changes when it's re-created, so you can't search in the log for the original commit (an option allows to reference it in the message log but you can't be sure it was used).

So you have to search for the log message:

git log --grep="the log message"

If result shows up, it'll be the cherry-picked commit.

CharlesB
  • 86,532
  • 28
  • 194
  • 218