I do
git pull
to get new commits from remote and merge them with my local branch.
How can I list the commits that "just came in" ?
I do
git pull
to get new commits from remote and merge them with my local branch.
How can I list the commits that "just came in" ?
You can use this:
git log @{1}..
This is the same as
git log currentbranch@{1}..currentbranch
where the @{1}
notation means "the commit the branch pointed to just before it last got updated".
This shows you exactly the commits that got merged.
If you do git pull
it automatically merges the commits; You can't look at just the new ones but git log
will give you a list of all commits.
If you merely fetch
ed the commits you could possibly list them before merging, but I think that might be slightly pointless.
Edit: A quick glance at the Internet seems to tell me that git log -p ..FETCH_HEAD
would list fetched but unmerged commits, as a fun fact of sorts, in case you ever find yourself needing to see only the fetched commits.
Another: ellotheth's link in their comment seems to have a solution that even works with pull. It seems to use git diff
but maybe git log ORIG_HEAD..
or similar would work, too?
...Nevertheless, using fetch
and merge
instead of pull
might actually be the sensible thing to do, especially if you are assuming you don't necessarily want to merge all the commits immediately, or at all.
I think
git log --topo-order
should work.
It is supposed to show the log entries in the order they came to the current branch - not the chronological order.
I would defer you to
git help log
to see the options that may help your case. Perhaps you are wanting the --first-parent
option?
I personally do this a lot:
git log -n 5 --oneline
If you are just interested in a specific branch (e.g., master
), you can take the line in the output of git fetch
that has that branch's name:
6ec1a9c..91f6e69 master -> origin/master
and use it to construct a git log
command
git log --graph --decorate 6ec1a9c..91f6e69
The two periods mean "all commits that are in the second commit (origin/master) but are not in the first (master)", which is what you are looking for.
First call git fetch
Then:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative master..origin/master
This will show something like this:
* d3e3a17 - (origin/master, origin/HEAD) Fix test (3 minutes ago)
* a065a9c - Fix exec count (4 minutes ago)
Related: How do I see the commit differences between branches in git?