This is my full git log.
$ git log --oneline --decorate
77cbdda (HEAD -> master) file4
8afab80 file3
9a4cd72 file2
76c2efc (origin/master) file1
I want to get log from origin/master to HEAD. When I tried
$ git log --oneline --decorate origin/master..HEAD
I got log msg like below
77cbdda (HEAD -> master) file4
8afab80 file3
9a4cd72 file2
But what I want is like below.
77cbdda (HEAD -> master) file4
8afab80 file3
9a4cd72 file2
76c2efc (origin/master) file1
How can I get log message like that?
用~1
git log --oneline --decorate origin/master~1..HEAD
origin/master..HEAD
means what exists in HEAD that is not in origin/master .
9a4cd72 (origin/master) file2
exists both HEAD and origin/master so, it is not in the list
$ git log --oneline --decorate origin/master~1..HEAD
This should work unless 76c2efc (origin/master)
is your very first commit. So, when trying origin/master~1
, you are getting error cause it does not exist in your working tree actually.
I've got the reason why I got error when I command
$ git log --oneline --decorate origin/master~1..HEAD
That's because origin/master was the . 。 If it was second commit or more, there is no error.
Thank Edmundo.
You can use
git log --oneline --decorate HEAD --not origin/master^@
The origin/master^@
will select all parents of origin/master
commit whenever it one, zero or many. And --not
will exclude this commits (and its parents) from listing.
Note: you need to exclude all the parents commits, because if you exclude only mainline parent origin/master~1
, then commits from all merged branches will got listed in case origin/master
is merge commit.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.