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)>
I finally found the way to do what the OP wanted. It's as simple as:
git log --graph [branchname]
The command will display all commits that are reachable from the provided branch in the format of graph. But, you can easily filter all commits on that branch by looking at the commits graph whose * is the first character in the commit line.
For example, let's look at the excerpt of git log --graph master on cakephp GitHub repo below:
D:\Web Folder\cakephp>git log --graph master
* commit 8314c2ff833280bbc7102cb6d4fcf62240cd3ac4
|\ Merge: c3f45e8 0459a35
| | Author: José Lorenzo Rodríguez
| | Date: Tue Aug 30 08:01:59 2016 +0200
| |
| | Merge pull request #9367 from cakephp/fewer-allocations
| |
| | Do fewer allocations for simple default values.
| |
| * commit 0459a35689fec80bd8dca41e31d244a126d9e15e
| | Author: Mark Story
| | Date: Mon Aug 29 22:21:16 2016 -0400
| |
| | The action should only be defaulted when there are no patterns
| |
| | Only default the action name when there is no default & no pattern
| | defined.
| |
| * commit 80c123b9dbd1c1b3301ec1270adc6c07824aeb5c
| | Author: Mark Story
| | Date: Sun Aug 28 22:35:20 2016 -0400
| |
| | Do fewer allocations for simple default values.
| |
| | Don't allocate arrays when we are only assigning a single array key
| | value.
| |
* | commit c3f45e811e4b49fe27624b57c3eb8f4721a4323b
|\ \ Merge: 10e5734 43178fd
| |/ Author: Mark Story
|/| Date: Mon Aug 29 22:15:30 2016 -0400
| |
| | Merge pull request #9322 from cakephp/add-email-assertions
| |
| | Add email assertions trait
| |
| * commit 43178fd55d7ef9a42706279fa275bb783063cf34
| | Author: Jad Bitar
| | Date: Mon Aug 29 17:43:29 2016 -0400
| |
| | Fix `@since` in new files docblocks
| |
As you can see, only commits 8314c2ff833280bbc7102cb6d4fcf62240cd3ac4 and c3f45e811e4b49fe27624b57c3eb8f4721a4323b have the * being the first character in the commit lines. Those commits are from the master branch while the other four are from some other branches.