Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the commands 'git diff --staged' and 'git diff --cached'

Tags:

git

I have just started learning git. I have a confusion between the commands git diff --staged and git diff --cached.

like image 258
Tanay Avatar asked Jul 07 '16 19:07

Tanay


2 Answers

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.

Git Workflow

like image 110
CodeWizard Avatar answered Sep 18 '22 17:09

CodeWizard


There is no difference between these two. From git diff docs:

--staged is a synonym of --cached.

like image 21
fracz Avatar answered Sep 21 '22 17:09

fracz