Why is git diff only working with option --cached?
up vote
1
down vote
favorite
If I execute git diff file.php
then I don't get any response.
I always have to execute git diff --cached file.php
.
Why is --cached not automatically executed and why do I have to do this?
I am using git version 2.17.0.windows.1
git
add a comment |
up vote
1
down vote
favorite
If I execute git diff file.php
then I don't get any response.
I always have to execute git diff --cached file.php
.
Why is --cached not automatically executed and why do I have to do this?
I am using git version 2.17.0.windows.1
git
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
If I execute git diff file.php
then I don't get any response.
I always have to execute git diff --cached file.php
.
Why is --cached not automatically executed and why do I have to do this?
I am using git version 2.17.0.windows.1
git
If I execute git diff file.php
then I don't get any response.
I always have to execute git diff --cached file.php
.
Why is --cached not automatically executed and why do I have to do this?
I am using git version 2.17.0.windows.1
git
git
asked 20 mins ago
Black
4,21784194
4,21784194
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
git diff <file>
compare the file in working dir vs in index.
So if you already added the file (by git add
) from working dir to index, then:
- there is no diff between working dir and index.
- but there is diff between the current commit (pointed by
HEAD
) and index, this diff is shown with the--cached
option.
add a comment |
up vote
1
down vote
The purpose of the git diff
command is to compare the state of your index with your files present on your filesystem.
That of the git diff --cached
command is to compare the state of your index with the commit your are pointing onto.
If you did changes to your file file.php
that you did not already stage (using git add
), then you should use git diff
in order to see the changes.
But if you already did git add
on this file, then a copy has been placed in your index, so to see the changes, you have to use the git diff --cached
command.
New contributor
You are right, there is no output after adding the file to the staging area! Thx!
– Black
10 mins ago
"that you did not already commit" should probably read "that you did not already stage/add"
– ohlec
6 mins ago
Thank you @ohlec, I typed too quicly ^^"
– mistiru
3 mins ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
git diff <file>
compare the file in working dir vs in index.
So if you already added the file (by git add
) from working dir to index, then:
- there is no diff between working dir and index.
- but there is diff between the current commit (pointed by
HEAD
) and index, this diff is shown with the--cached
option.
add a comment |
up vote
2
down vote
accepted
git diff <file>
compare the file in working dir vs in index.
So if you already added the file (by git add
) from working dir to index, then:
- there is no diff between working dir and index.
- but there is diff between the current commit (pointed by
HEAD
) and index, this diff is shown with the--cached
option.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
git diff <file>
compare the file in working dir vs in index.
So if you already added the file (by git add
) from working dir to index, then:
- there is no diff between working dir and index.
- but there is diff between the current commit (pointed by
HEAD
) and index, this diff is shown with the--cached
option.
git diff <file>
compare the file in working dir vs in index.
So if you already added the file (by git add
) from working dir to index, then:
- there is no diff between working dir and index.
- but there is diff between the current commit (pointed by
HEAD
) and index, this diff is shown with the--cached
option.
answered 9 mins ago
Kata
817410
817410
add a comment |
add a comment |
up vote
1
down vote
The purpose of the git diff
command is to compare the state of your index with your files present on your filesystem.
That of the git diff --cached
command is to compare the state of your index with the commit your are pointing onto.
If you did changes to your file file.php
that you did not already stage (using git add
), then you should use git diff
in order to see the changes.
But if you already did git add
on this file, then a copy has been placed in your index, so to see the changes, you have to use the git diff --cached
command.
New contributor
You are right, there is no output after adding the file to the staging area! Thx!
– Black
10 mins ago
"that you did not already commit" should probably read "that you did not already stage/add"
– ohlec
6 mins ago
Thank you @ohlec, I typed too quicly ^^"
– mistiru
3 mins ago
add a comment |
up vote
1
down vote
The purpose of the git diff
command is to compare the state of your index with your files present on your filesystem.
That of the git diff --cached
command is to compare the state of your index with the commit your are pointing onto.
If you did changes to your file file.php
that you did not already stage (using git add
), then you should use git diff
in order to see the changes.
But if you already did git add
on this file, then a copy has been placed in your index, so to see the changes, you have to use the git diff --cached
command.
New contributor
You are right, there is no output after adding the file to the staging area! Thx!
– Black
10 mins ago
"that you did not already commit" should probably read "that you did not already stage/add"
– ohlec
6 mins ago
Thank you @ohlec, I typed too quicly ^^"
– mistiru
3 mins ago
add a comment |
up vote
1
down vote
up vote
1
down vote
The purpose of the git diff
command is to compare the state of your index with your files present on your filesystem.
That of the git diff --cached
command is to compare the state of your index with the commit your are pointing onto.
If you did changes to your file file.php
that you did not already stage (using git add
), then you should use git diff
in order to see the changes.
But if you already did git add
on this file, then a copy has been placed in your index, so to see the changes, you have to use the git diff --cached
command.
New contributor
The purpose of the git diff
command is to compare the state of your index with your files present on your filesystem.
That of the git diff --cached
command is to compare the state of your index with the commit your are pointing onto.
If you did changes to your file file.php
that you did not already stage (using git add
), then you should use git diff
in order to see the changes.
But if you already did git add
on this file, then a copy has been placed in your index, so to see the changes, you have to use the git diff --cached
command.
New contributor
edited 4 mins ago
New contributor
answered 12 mins ago
mistiru
114
114
New contributor
New contributor
You are right, there is no output after adding the file to the staging area! Thx!
– Black
10 mins ago
"that you did not already commit" should probably read "that you did not already stage/add"
– ohlec
6 mins ago
Thank you @ohlec, I typed too quicly ^^"
– mistiru
3 mins ago
add a comment |
You are right, there is no output after adding the file to the staging area! Thx!
– Black
10 mins ago
"that you did not already commit" should probably read "that you did not already stage/add"
– ohlec
6 mins ago
Thank you @ohlec, I typed too quicly ^^"
– mistiru
3 mins ago
You are right, there is no output after adding the file to the staging area! Thx!
– Black
10 mins ago
You are right, there is no output after adding the file to the staging area! Thx!
– Black
10 mins ago
"that you did not already commit" should probably read "that you did not already stage/add"
– ohlec
6 mins ago
"that you did not already commit" should probably read "that you did not already stage/add"
– ohlec
6 mins ago
Thank you @ohlec, I typed too quicly ^^"
– mistiru
3 mins ago
Thank you @ohlec, I typed too quicly ^^"
– mistiru
3 mins ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204338%2fwhy-is-git-diff-only-working-with-option-cached%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password