How can I see incoming commits in git?

Benjamin Pollack picture Benjamin Pollack · Aug 26, 2009 · Viewed 67.3k times · Source

Possible Duplicate:
Using Git how do I find modified files between local and remote

How can I see incoming commits in git? Or even better, see what I just git fetch/git pulled?

Edit: To clarify the question: someone tells me that, to get some fixes, I should pull from their repository. My goal is to see what their changes are before I accept them. git pull automatically merges, which is not what I want. git fetch will grab them without merging, but I'm unsure how to view what exactly I just pulled in. The reason for the original phrasing is that I normally use Mercurial, where the command would be hg incoming <repo name here>—a command for which git seems to lack an analog.

Answer

Dustin picture Dustin · Aug 26, 2009

incoming isn't quite a direct mapping in git because you can (and I often do) have multiple repos you're pulling from, and each repo has multiple branches.

If there were an equivalent of hg's incoming command, it'd probably be this:

git fetch && git log ..origin/master

That is, "go grab all of the stuff from the upstream, and then compare my current branch against the upstream master branch."

Similarly, outgoing would be this:

git fetch && git log origin/master..

In practice, I just type those manually (even though I created an alias for one of them) because it's easy to have lots of local branches tracking and being tracked by lots of remote branches and have no trouble keeping it together.