48

I'd like to see the file permission as it exists in the repository index.

How can this be done?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286

2 Answers2

68

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.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
11

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)

zigarn
  • 10,892
  • 2
  • 31
  • 45