I'd like to see the file permission as it exists in the repository index.
How can this be done?
1 Answer. Show activity on this post. When Git checks out files, it by default uses the umask of the file on the system, setting the executable bit if it's a directory or it's marked as an executable file. That's because Git removes and re-creates the file, so it doesn't preserve the permissions of the existing file.
Git tracks exactly one bit of permission: executable or not executable. You don't say what you mean precisely by "it stopped taking file permission changes into account", but my best guess is that you didn't change the executable permission, and so from Git's point of view, there was no change to take into account.
Use git ls-files -s <file>
:
Show staged contents' mode bits, object name and stage number in the output.
Note that Git only tracks files' executable bit. You'll only ever see 644 or 755.
ls-files
:
Show information about files in the index and the working tree
--stage
: Show staged contents' mode bits, object name and stage number in the output.
$ git ls-files --stage 100644 b5ff1408aca94e2f33b9af9299b38764c2ec0bb7 0 .editorconfig 100644 4ef3204cd0928c0460274208c40a9e63b6c58beb 0 .gitignore
File mode is the last 3 digits of the first number. (see index-format)
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