I have several git branches that have commits cherry-picked between them. Commits are sometimes squashed.
In order to decide whether to apply a commit abcdef
to the live
branch, I want to find out if an equivalent commit has already been applied to the preprod
branch.
If preprod
never squashed commits, I would use patch IDs, as discussed in this question. Since preprod
may squash sequences of commits, I want to see if abcdef
would be an empty commit on preprod
.
$ git checkout preprod
$ git cherry-pick abcdef
On branch preprod
Your branch is up-to-date with 'origin/preprod'.
You are currently cherry-picking commit abcdef.
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:
git commit --allow-empty
Otherwise, please use 'git reset'
How can I programmatically detect if cherry-picking a commit would result in an empty commit?
(I know this is an imperfect heuristic for detecting whether the patch has been applied, but it's good enough for my use case.)