I have just started learning git. I have a confusion between the commands git diff --staged
and git diff --cached
.
Asked
Active
Viewed 364 times
5

Mad Physicist
- 107,652
- 25
- 181
- 264

Tanay
- 181
- 8
-
2Possible duplicate of [What are the differences between these git diff commands?](http://stackoverflow.com/questions/3686452/what-are-the-differences-between-these-git-diff-commands) – Eli Sadoff Jul 07 '16 at 19:53
-
1Start with [Pro Git](http://git-scm.com/book). – kostix Jul 07 '16 at 20:18
-
1If you wonder about a specific command like this, your first step should be to check the help for that command. Type `git diff --help` and then search for the specific arguments. – Alderath Jul 08 '16 at 07:08
2 Answers
7
In old versions of git, the staging area was referred to as cache/stage area. Today it's being called index.
From the docs:
--staged
is a synonym of--cached
.
Stage/cache/index are all synonyms for the staging area. It simply depends on the git version you use. It was changed to index along the way (and today it's called index), but there are still a few commands which use --cached
, like git diff
, git rm --cached
, etc.

Robin A. Meade
- 1,946
- 18
- 17

CodeWizard
- 128,036
- 21
- 144
- 167
-
-
1Added image so you can have a better picture what is this, its called the 3-states – CodeWizard Jul 07 '16 at 20:02
-
-
Sure. i have posted you a FB git group which i manage, [https://www.facebook.com/groups/git.dvcs/] – CodeWizard Jul 07 '16 at 20:03
-
Here are some cool answers which you can learn form a lot of stuff. simply click on my profile and read answer which i gave. like this one: http://stackoverflow.com/questions/34519665/how-to-move-head-back-to-a-previous-location-detached-head/34519716#34519716 – CodeWizard Jul 07 '16 at 20:04
2
There is no difference between these two. From git diff
docs:
--staged
is a synonym of--cached
.
-
Hi! Thanks for your answer. I am currently just rote learning the commands. Could you recommend me something that I could understand stuff? Thanks. – Tanay Jul 07 '16 at 19:57
-
Here is a good place to star with: git scm, [https://www.facebook.com/groups/git.dvcs/] , [https://www.atlassian.com/git/] – CodeWizard Jul 07 '16 at 19:59
-
[Git book](https://git-scm.com/book/en/v2) is what you should start with. – fracz Jul 07 '16 at 19:59