For those still looking for a simple answer, check out git cherry. It compares actual diffs instead of commit hashes. That means it accommodates commits that have been cherry picked or rebased.
First checkout the branch you want to delete:
git checkout [branch-to-delete]
then use git cherry to compare it to your main development branch:
git cherry -v master
Example output:
+ 8a14709d08c99c36e907e47f9c4dacebeff46ecb Commit message
+ b30ccc3fb38d3d64c5fef079a761c7e0a5c7da81 Another commit message
- 85867e38712de930864c5edb7856342e1358b2a0 Yet another message
Note: The -v
flag is to include the commit message along with the SHA hash.
Lines with the '+' in front are in the branch-to-delete, but not the master branch. Those with a '-' in front have an equivalent commit in master.
For JUST the commits that aren't in master, combine cherry pick with grep:
git cherry -v master | grep "^\+"
Example output:
+ 8a14709d08c99c36e907e47f9c4dacebeff46ecb Commit message
+ b30ccc3fb38d3d64c5fef079a761c7e0a5c7da81 Another commit message