Here are two different questions but I think they are related.
When using Git, how do I find which changes I have committed locally, but haven\'t yet pushed
I would do
$ git fetch --dry-run
for hg incoming
and
$ git push --dry-run
for hg outgoing
.
Starting with Git 1.7.0, there is a special syntax that allows you to generically refer to the upstream branch: @{u}
or @{upstream}
.
To mimic hg incoming
:
git log ..@{u}
To mimic hg outgoing
:
git log @{u}..
I use the following incoming
and outgoing
aliases to make the above easier to use:
git config --global alias.incoming '!git remote update -p; git log ..@{u}'
git config --global alias.outgoing 'log @{u}..'
When the "git log" and @{u} answers initially gave me "unknown revision" errors, I tried out Chris/romkyns suggestion of git push --dry-run
.
You will get an output such as "5905..4878 master->master". 5905 is the latest commit that the remote has and commits through (and including) 4878 will be applied to the remote.
You can then use 5905..4878 as arguments to several other git commands to get more details:
git diff 5905..4878 # Gives full code changes in diff style
git log --online 5905..4878 # Displays each commit's comment
There's also this, for comparing all branches:
git log --branches --not --remotes=origin
This is what the git log man page says about this:
Shows all commits that are in any of local branches but not in any of remote tracking branches for origin (what you have that origin doesn’t).
The above is for outgoing
.
For incoming
, just swap:
git log --remotes=origin --not --branches
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