40

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

How can this be done?

Chris Stryczynski
  • 25,295
  • 38
  • 135
  • 245

2 Answers2

56

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.

Chris
  • 112,704
  • 77
  • 249
  • 231
6

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
  • 9,832
  • 2
  • 30
  • 42