Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git current branch commits list

Tags:

git

When you do a Pull Request in Github or Stash you get a list of the commit from your current branch.

What would be the git command to get a list of the commit which makes up the current branch without specifying the name of the branch which we started from?

like image 433
Laurent Kempé Avatar asked Jun 07 '26 20:06

Laurent Kempé


1 Answers

You usually need to know from which branch you are coming from in order to list the commit specific to your current branch, as I explained in "Git log to get commits only for a specific branch"

Otherwise, you need to exclude the commits which are not part of only your branch (as suggested by dimirc):

git log mybranch --not $(git for-each-ref --format='%(refname)' refs/heads/ | grep -v "refs/heads/mybranch")

Or simpler, using git merge-base (if HEAD is not on your branch as in this question):

git log $(git merge-base HEAD branch)..branch
like image 191
VonC Avatar answered Jun 10 '26 20:06

VonC