98

Possible Duplicate:
How can I see incoming commits in git?

What is the git equivalent of of "hg outgoing" or "hg incoming"?

In Mercurial, hg outgoing lists the changesets that are newer than what's on the server and will be sent if I were to do hg push. Same in reverse for hg incoming and hg pull.

Community
  • 1
  • 1
Robert Martin
  • 16,759
  • 15
  • 61
  • 87

1 Answers1

102

If you want to list commits that are on branch B but not on branch A, do git log A..B.

If you want to list commits that are on your local branch dev, but not the the remote branch origin/dev, do:

git fetch origin             # Update origin/dev if needed
git log origin/dev..dev

If you want to list commits that are on the remote branch, but not on the local branch, simply do the converse:

git fetch origin             # Update origin/dev if needed
git log dev..origin/dev

Note: you might find it easier to compare branches graphically using gitk origin origin/dev

adl
  • 15,627
  • 6
  • 51
  • 65
  • 4
    What if I want a list of commits that are in my repo, but not on the remote, regardless of branch? – Jorn Feb 20 '15 at 15:03
  • 1
    @Jorn The [man page for `git log`](https://www.kernel.org/pub/software/scm/git/docs/git-log.html) has an example section where you will find an example that does exactly that. (If you don't find it, please submit this as a separate question as it is not related to the original question.) – adl Feb 26 '15 at 09:20
  • 11
    @adl, hmm, `hg outgoing` shows all branches which is exactly what @Jorn is asking for. So, that would mean the answer is invalid for this question… or the answer doesn’t discuss how `hg push`’s default behavior is more like `git push --mirror` than `git push` ;-). – binki Apr 28 '15 at 19:52
  • 5
    How do you do it without fetching? I don't want to mutate my local repository, I just want to see what would happen if I did a fetch, but without actually doing it. – Jason S Nov 16 '15 at 23:05
  • 1
    Yes, you are all correct - this does not answer the question "what if I pull?" and "what if I push?" completely, but still - this is waaay better than nothing ;) This also has general utility for comparing branches (not only remote tracking ones). – Tomasz Gandor Jan 10 '16 at 23:50
  • 30
    So to answer the original question (which this answer doesn't). `hg outgoing` can be done in git via `git log --branches --not --remotes=origin` – Michael Mar 31 '16 at 07:57
  • I found this post by searching for *git equivalent of hg view*. It turns out `gitk` was exactly what I was looking for. – kasperd Jan 09 '19 at 09:00
  • @Michael why not post it as an answer instead? It's easier to see it then and we can upvote your more correct answer – OZZIE Sep 13 '19 at 06:24
  • @OZZIE I think the question was closed quite a while before I answered so wasn't able to unfortunately. – Michael Sep 13 '19 at 06:36