69

I'm trying to view changes for a single file that is unstaged.

First I use git status to view all the unstaged changes then for example:

git diff AndroidManifest.xml

But I get this output:

diff --git a/AndroidManifest.xml b/AndroidManifest.xml  
old mode 100755  
new mode 100644

What does that mean and how can I view changes for specific file?

Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57
pedja
  • 3,285
  • 5
  • 36
  • 48

2 Answers2

55

Most probably, the contents of this file haven't changed, only the executable bit has been cleared. Try actually changing the file by, say, appending an empty line to it, and see what git diff outputs.

Apart from file contents, Git also records the state of the executable bit for each file. It makes sense on Linux systems if you want scripts to be executable right after checkout. See also the following two related questions:

How do I make Git ignore file mode (chmod) changes?

How do I remove files saying "old mode 100755 new mode 100644" from unstaged changes in Git?

Community
  • 1
  • 1
krlmlr
  • 25,056
  • 14
  • 120
  • 217
25

It means that the file mode changed from 755 to 644, but the contents were not altered.

git diff is exactly what you are looking for - it shows the changes from unstaged files to the last commit. git diff --cached is for staged files.

Polygnome
  • 7,639
  • 2
  • 37
  • 57
  • 4
    Can I avoid this file mode change? – ManuelSchneid3r May 07 '17 at 20:42
  • 3
    @ManuelSchneid3r Sure, of course. Git does not change the file mode, it only tracks that the mode change happened. Either simply change it back to its original mode or don't change it in the first place. – Polygnome May 07 '17 at 21:10