Create a readme.txt file with the contents of "hello world!", And index it

git add readme.txt 

I change the contents of the file to "hello git!", I run the git status command

 git status -s AM readme.txt 

The git diff --cached and git diff --staged produce the same result.

 diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..a042389 --- /dev/null +++ b/readme.txt @@ -0,0 +1 @@ +hello git! 

What is the difference between these two parameters? If there is a difference, how to create a situation when it manifests itself?

  • one
    Such variants appear because the development of git is in general non-linear and evolutionary. At first, one of the options appeared, then for uniformity of parameters, a second one was added, and the old one was left for backward compatibility. - Nick Volynkin

1 answer 1

according to git diff documentation :

--staged is a synonym of --cached

transfer:

--staged is a synonym for --cached