3
votes

If I do git ls-tree branchname path/to/directory I get the following output:

100644 blob d7cf85396913fb7169a881d8334f32af153122eb    .gitignore
100644 blob ba7adb479be66d8f1d62384ab53997cddd465110    .travis.yml
040000 tree 2de254bbec97958db2375e2d0ab767b23315ab50    application

So I'm seeing the following permissions set:

100644 for blobs, 040000 for trees

From what I've read 100644 can be interpreted like - regular file with sticky bit of 0 and file permissions of 644 (not executable by anyone), 040000 - directory with sticky bit of 0 and no permissions. Instead of 644 for blob, 755 is also possible since I've read git tracks only executable bits.

My question is how exactly does git use these permissions? Does it apply them to files and folders in working tree when checking out branch? Or does it use them internally somehow?

PS. Please note, this question is NOT about what those permissions stand for.

1

1 Answers

2
votes

Git uses these permission to determine the type of a directory entry on checkout and to set the execute permission flag if necessary. As far as I know, they are not used in any other way.

In git, there are fewer file modes than in a standard posix file system:

  • 100644: normal files
  • 100755: executable files
  • 040000: directories
  • 120000: symlinks