1

There is a file, git st gets:

# On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: lib/ABC/Main.pm # no changes added to commit (use "git add" and/or "git commit -a") 

git diff gets:

diff --git a/lib/ABC/Main.pm b/lib/ABC/Main.pm old mode 100755 new mode 100644 

git diff HEAD gets the same.

After adding file, git diff shows nothing.

git diff HEAD gets:

diff --git a/lib/ABC/Main.pm b/lib/ABC/Main.pm old mode 100755 new mode 100644 

How to show just differences from git diff rightly?

1 Answer 1

2

This is because the only changes to Main.pm are the file permissions. There are no differences in file content.

Sign up to request clarification or add additional context in comments.

4 Comments

I think this answer's not true. Changes are changes to git. No matter is change is in content or permissions. Git tracks permissions on file systems that have them. The fact that the author has accepted make me think I had not understood the question (or it was badly formulated).
@eleom, The output of the diff command showed the permission changes. From this I knew the differences were file permissions.
@user3021843 Yes, I also saw that. And I thought edem also had seen that, and he was complaining because after adding, git diff said nothing while he knew they were different (because of permissions). It's clear now he hadn't realized. But then, I don't understand the question. As your answer solved edem's problem, I remove my downvote on your answer. I downvote edem's question now, cause in my opinion, it's not clear what he is asking for. To remove my downvote to your answer, I need you to edit your post (Stack Overflow doesn't allow me to do it otherwise).
@eleom The author just forgot that file permissions had been changed. Thank you for your attention.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.