I’d like to script, preferably in rake, the following actions into a single command:
- Get the version of my local git repository.
- Git pull the latest code.
- Git diff from the version I extracted in step #1 to what is now in my local repository.
In other words, I want to get the latest code form the central repository and immediately generate a diff of what’s changed since the last time I pulled.
You could do this fairly simply with refspecs.
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:
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: