Sebastien Diot
Sebastien Diot

Reputation: 7359

Strange behaviour in GIT diff HEAD

I am under Windows and using GIT strictly locally, as a backup system.

I have my whole Eclipse workspace in it.

Searching on the net, I find that I need to do this:

Display changes since last commit:
$ git diff HEAD

I am trying to understand what precisely some maven plugin goal is doing. So I commit all my changes. Then I run the maven command. Then I go in the project directory, which is under the workspace directory, and run

git diff HEAD

It then shows me changes for the whole workspace, when in fact nothing has changed except in this directory. If I redirect it to a file, the file is 157M big!

But if I go one directory up, back in the workspace, and do the same, then it only shows me the change in the project directory. Which is what I would expect.

So my questions are:

1) Why, if I go in a sub-directory, it shows me changes that happened in the parent directory?

2) When there really is only that one change, where does it get the 157M of changes?

Upvotes: 1

Views: 442

Answers (1)

John Flatness
John Flatness

Reputation: 33749

Calling git diff without a path argument anywhere inside a git repository will show you the differences for the whole repository, not just the current directory (this is different than Subversion's behavior).

If you're getting different output from git diff HEAD in different directories, it means that you're moving to a different repository (or you're not actually running the exact same command).

Upvotes: 1

Related Questions