Ogen
Ogen

Reputation: 6709

What is the difference between diff and diff-index with these flags

I have these two git commands

git diff-index --cached --name-status HEAD

and

git diff --cached --name-status

I can't see the difference between them. I've been experimenting with adding and modifying and deleting files on my branch and running these commands but they seem to be giving me the same results.

Upvotes: 1

Views: 75

Answers (1)

VonC
VonC

Reputation: 1326736

Since you don't specify paths to git diff or git diff-index, both will by default compare:

  • HEAD (if you don't specify it, it is the tree-ish used by default)
  • and the index (because of the --cached, which does not consider the on-disk file at all)

So it seems normal they return the same result.

Upvotes: 1

Related Questions