I'd like to script, preferably in rake, the following actions into a single command:
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.
git fetch git log --name-status origin/master.. Will show you what commits you are about to retrieve, along with the names of the files. Based upon this reply the command "git log --graph -p" is doing a nice job. It shows tree information about the history and code changes as well.
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch.
The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.
You could do this fairly simply with refspecs.
git pull origin git 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 origin git 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}..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With