How can I generate a git diff of what's changed since the last time I pulled? How can I generate a git diff of what's changed since the last time I pulled? git git

How can I generate a git diff of what's changed since the last time I pulled?


You could do this fairly simply with refspecs.

git pull origingit diff @{1}..

That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly record the current version:

current=`git rev-parse HEAD`git pull origingit diff $current..

I personally use an alias that simply shows me a log, in reverse order (i.e. oldest to newest), sans merges, of all the commits since my last pull. I run this every time my pull updates the branch:

git config --global alias.lcrev 'log --reverse --no-merges --stat @{1}..


Greg's way should work (not me, other Greg :P). Regarding your comment, origin is a configuration variable that is set by Git when you clone the central repository to your local machine. Essentially, a Git repository remembers where it came from. You can, however, set these variables manually if you need to using git-config.

git config remote.origin.url <url>

where url is the remote path to your central repository.

Here is an example batch file that should work (I haven't tested it).

@ECHO off:: Retrieve the changes, but don't merge them.git fetch:: Look at the new changesgit diff ...origin:: Ask if you want to merge the new changes into HEADset /p PULL=Do you wish to pull the changes? (Y/N)IF /I %PULL%==Y git pull


This is very similar to a question I asked about how to get changes on a branch in git. Note that the behaviour of git diff vs. git log is inconsistently different when using two dots vs. three dots. But, for your application you can use:

git fetchgit diff ...origin

After that, a git pull will merge the changes into your HEAD.