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?
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.
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.
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.
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.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With