What does the value of / dev / null mean in git show commit?

What does --- /dev/null mean in a git show commit expression?

This is adding a new file, so I assume it said nothing was deleted, but why the link to /dev/null ?

 $ git show a395a commit a395a7bb4abcc606022ac14a07794b2d3c18bd5b Author: David Banks < BanksySan@googlemail.com > Date: Sun Apr 12 17:41:08 2015 +0100 My first commit. diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +Hello 
+5
source share
2 answers

This means that since test.txt is a new file, in the diff shown it was compared to "nothing"; "file" / dev / null.

+9
source

You can find this convention (diff versus "no file") from the very beginning of Git itself.

The goal was to look more like a gc-patch Linux tool that uses a patch from a file, input, or commit.

See commit 2f97813 , Git 0.99, April 2005:

Make diff-cache , and friends output more cg-patch .

This changes the way the default arguments for diff are constructed when diff-cache and friends are called with -p and there is no GIT_EXTERNAL_DIFF environment variable.
He is trying to be more friendly cg-patch :

  • Display differences with /dev/null to indicate added or deleted files ;
  • Display file modes for existing files as comments after the diff label.
+4
source

All Articles