Is there a shorter way to write git diff HEAD ^ HEAD?

I find that I type this quite often, for example, when I made some changes, made it, and then either need to look for what I did there to find out what to do next, or make sure that I did not add anything inadvertently to the commit before clicking on the remote computer.

Suppose diff HEAD^ HEAD is fast enough to print ( git di TAB H TAB ^ H TAB ), but it still seems like there should be a better way.

How can I see all the changes made in the last commit?

+5
source share
4 answers

Try git show . Without other parameters, it shows the difference between the last latch.

git show $something displays the contents of $something user-friendly way. When $something refers to a file, git show displays the contents of the file. When it refers to commit, Git shows commit (author, date, commit log, and diff). git show without additional arguments is equivalent to git show HEAD .

+9
source

You can use one of the following actions:

(choose the one that suits you and make it an alias).

 # the equivalent command (dry run) for pull/push git log ^branch1 branch2 git log branch1 ^branch 2 

git show

 # to view the content of the last commit git show 

Shows one or more objects (drops, trees, tags and commits).

For commits, it shows a log message and text difference . It also presents a merge commit in a special format created by git diff-tree --cc.


git log --cc

From git v> 2.6, you have the --cc flag added to the log so you can use

 git log --cc 

It will also display a complete log with a difference.

enter image description here


git diff-tree --cc HEAD

Very similar to git log --cc . Behind the scenes, git show is an alias for this command.

enter image description here

+4
source

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

 git diff @^ @ 

or

 git show @ 

also an option.

+4
source

A pretty nice way would be to use an alias. Of course, this is a quick fix, but

 $> alias gd="diff HEAD^ HEAD" 

would do the trick. Now you can use:

 $> gd 

and your team will be launched.

Add the alias command to your ~/.bashrc or similar, and you do not need to write it at the beginning of each console session.

0
source

Source: https://habr.com/ru/post/1244574/


All Articles