Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-diff

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?

like image 552
leftaroundabout Avatar asked Mar 07 '16 12:03

leftaroundabout


2 Answers

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.

like image 58
nwellnhof Avatar answered Oct 06 '22 04:10

nwellnhof


I also found in this post that @ is a shortcut for HEAD. So

git diff @^ @

or

git show @

is also an option.

like image 33
leftaroundabout Avatar answered Oct 06 '22 02:10

leftaroundabout