git cherry: How to identify equivalent commit by commit message

Viewed 765

In my project there are a stable branch and a dev branch. Commits are cherry-picked from dev branch to stable branch.

In order to filter all commits on dev that have not been merged to stable, git cherry -v stable dev looks like a good choice. However it identifies equivalence by diff, which usually changes after resolving merge conflict during cherry-pick:

The equivalence test is based on the diff, after removing whitespace and line numbers. git-cherry therefore detects when commits have been "copied" by means of git-cherry-pick(1), git-am(1) or git-rebase(1).

I was wondering that is there any command that works like git cherry, but identifies equivalent commits by commit message?

3 Answers

You want to use patch-id. This is the mechanism used by git cherry.

To find an equivalent of commit 3642151 run:

git show 3642151 | git patch-id

You should get a line with two hashes; the first is the patchid (call it PATCHID_FROM_ABOVE)

git log -p | git patch-id | grep PATCHID_FROM_ABOVE

This should give you a list of all commits that correspond to that patchid.

Stolen from: http://git.661346.n2.nabble.com/git-cherry-to-find-equivalent-commit-IDs-td3440883.html

Related