In git it's not possible to only list commits for a specific branch without specifying references you want to exclude.
But you could determine the references programatically, such a command could look like this:
git log HEAD $(git branch -a | grep -v "^*" | grep -v "\->" | sed "s/^ /--not /")
For easier usage you could define an alias:
git config --global alias.branchlog '!git log HEAD $(git branch -a | grep -v "^*" | grep -v "\->" | sed "s/^ /--not /")'
And then just use it by typing git branchlog
.
Note: If you want to ignore remote
branches, you have to remove the -a
option from the git branch -a
call.
This command will log all commits which are ONLY reachable from the current HEAD. It achieves this by listing all branches (git branch -a
), removing the current branch from the result and remote HEADs (grep -v "^*"
and grep -v "\->"
).
In the last step it prepends --not
to each branch to tell git log
to exclude this reference.
Note: Remote HEADs look like this remote/origin/HEAD -> remote/origin/master
and mess with git log
.
If you would type the command by hand it could look like this:
git log HEAD --not master --not origin/master