I want to list all commits that are only part of a specific branch.
With the following, it lists all the commits from the branch, but also from the parent (master)>
Fast answer:
git log $(git merge-base master b2)..HEAD
Let's say:
That you have a master branch
Do a few commits
You created a branch named b2
Do git log -n1; the commit Id is the merge base between b2 and master
Do a few commits in b2
git log will show your log history of b2 and master
Use commit range, if you aren't familiar with the concept, I invite you to google it or stack overflow-it,
For your actual context, you can do for example
git log commitID_FOO..comitID_BAR
The ".." is the range operator for the log command.
That mean, in a simple form, give me all logs more recent than commitID_FOO...
Look at point #4, the merge base
So: git log COMMITID_mergeBASE..HEAD will show you the difference
Git can retrieve the merge base for you like this
git merge-base b2 master
Finally you can do:
git log $(git merge-base master b2)..HEAD