Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean when Git diff shows mode changes?

Tags:

git

git-diff

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?

like image 519
pedja Avatar asked May 25 '13 09:05

pedja


People also ask

What is mode changed in git?

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.

How do I see changes in git diff?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.

Why git diff does not show changes?

Your file is already staged to be committed. You can show it's diff using the --cached option of git. To unstage it, just do what git status suggests in it's output ;) You can check The Git Index For more info.

What does diff mean in git?

Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.


2 Answers

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?

like image 179
krlmlr Avatar answered Sep 22 '22 07:09

krlmlr


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.

like image 26
StandByUkraine Avatar answered Sep 25 '22 07:09

StandByUkraine