Austin Schaefer
Austin Schaefer

Reputation: 696

Result of 'git diff' without additional parameters?

I checked the names of changed files using git diff master --name-only, and recieved a result of my changes similar to the following:

really/long/path/to/file.java
really/long/path/to/fileNumber2.java    
really/long/path/to/fileNumber3.java
really/long/path/to/fileNumber4.java

After this, I ran git diff without any extra parameters and got a large list of changes in the codebase that were not from those files. My question is, what comparison does a simple git diff make?

My guess is: it shows the difference between the latest and previous commits, but a man git-diff and a bit of reading didn't make things clearer for me.

Upvotes: 1

Views: 1876

Answers (1)

poke
poke

Reputation: 387507

As explained by the documentation, just calling git diff without specifying any revision will show you the changes relative to the index, i.e. all pending changes that appear in the “Changes not staged for commit” list when running git status.

git diff [--options] [--] [<path>…​]

This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell Git to further add to the index but you still haven’t. You can stage these changes by using git-add[1].

Upvotes: 3

Related Questions