List All Changes from a Git Pull, Merge, or Fast-Forward

When you pull and update your local, it would be nice to easily see all the commits that you have applied in the pull. Sure you can figure it by scanning through the git log carefully, but adding the following to your ‘~/.gitconfig’ gives you an easy way to see it in a glance:

whatsnewlog = !"sh -c "git log  --graph --pretty=format:'%Creset%C(red bold)[%ad] %C(blue bold)%h%C(magenta bold)%d %Creset%s %C(green bold)(%an)%Creset'  --abbrev-commit --date=short $(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)@..$(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)""
whatsnew = !"sh -c "git diff  $(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)@..$(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)""

When you pull, the HEAD of the current branch fast-forwards to the end of all the new commits. HEAD@ refers to the previous position of HEAD, so ‘git diff HEAD@..HEAD shows you all the stuff in the current HEAD that was not in the previous HEAD position. The same applies to branch references, and the messy stuff ‘\$(...)’ is simply to get the current branch name (using the branch name is better than HEAD, because it will have correct behavior even if you do a pull and checkout another branch). The fancy colors (‘%C(...)‘) will only work with Git 1.6.6 or later, so you can remove it if you do not want it.

Share