tags:

views:

5271

answers:

3

Here are 2 different questions but I think they are related.

  1. When using git how do I find which changes I have committed locally but haven't yet pushed to a remote branch? I'm looking for something similar to the Mercurial command "hg outgoing"

  2. When using git how do I find what changes a remote branch has prior to doing a pull? I'm looking for something similar to the Mercurial command "hg incoming"

Also for 2. is there a way to see what is available and then cherry-pick the changes I want to pull?

+10  A: 
  1. Use "git log origin..HEAD"

  2. Use "git fetch" followed by "git log HEAD..origin". You can cherry-pick individual commits using the listed commit ids.

The above assumes, of course, that "origin" is the name of your remote tracking branch (which it is if you've used clone with default options).

Greg Hewgill
(And if you’re not tracking the remote branch, it’s “git log origin/master..HEAD”.)
plindberg
+1  A: 

Not a full answer but git fetch will pull the remote repo and not do a merge. You can then do a

git diff master origin/master

Martin Redmond
+14  A: 

Git can't send that kind of information over the network, like Hg can. But you can run git fetch (which is more like hg pull than hg fetch to fetch new commits from your remote servers.

So, if you have a branch called master and a remote called origin, after running git fetch, you should also have a branch called origin/master. You can then get the git log of all commits that master needs to be a superset of origin/master by doing git log master..origin/master. Invert those two to get the opposite.

A friend of mine, David Dollar, has created a couple of git shell scripts to simulate hg incoming/outgoing. You can find them at http://github.com/ddollar/git-utils.

Jordi Bunster