9

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" ?

Alex
  • 32,506
  • 16
  • 106
  • 171

7 Answers7

17

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.

opqdonut
  • 5,119
  • 22
  • 25
3

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 fetched 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.

Community
  • 1
  • 1
2

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.

Alex
  • 32,506
  • 16
  • 106
  • 171
1

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

eternalmatt
  • 3,524
  • 4
  • 25
  • 25
  • `git log -n 5` is not sufficient as the new commits might be a not the top-most entries (if they were comited a month a go but pushed today) – Alex Aug 31 '12 at 14:29
1

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.

Jian
  • 10,320
  • 7
  • 38
  • 43
1

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?

Gelldur
  • 11,187
  • 7
  • 57
  • 68
-1

it's

git log

you are looking for

doc about git log

  • let's suppose your last commit were 2 weeks ago, then with `git log --after="2 weeks ago"` will display the log from today to 2 weeks ago. Hope this could help. –  Aug 31 '12 at 14:47
  • Still this would not do the job if somebody commited something 4 weeks ago but did not push. He pushes now and I pull. So I would not see his commit as "new". – Alex Aug 31 '12 at 17:04