Search code examples
gitgit-diff

Is the a shorter way of writing git diff HEAD^ HEAD?


I find myself typing this pretty often, like when I made some change, committed it, and then either need to look up something I did there to figure out what to do next, or make sure I didn't add anything unintended to the commit before pushing it to a remote.

Admittedly, diff HEAD^ HEAD is fast enough to type (git diTABHTAB^ HTAB), but it still feels like there should be a better way.

How do I easiest see all changes made in the last commit?


Solution

  • Try git show. Without other options, it shows a diff of the latest commit.

    git show $something shows the content of $something in a user-friendly way. When $something refers to a file, git show will display the file's content. When it refers to a commit, Git shows the commit (author, date, commit log and diff). git show without more arguments is equivalent to git show HEAD.