1

According to the "Git Internals - Git Objects" chapter of the "Pro Git" book (2nd ed.) each entry in a tree object has a mode.

a mode of 100644 [...] means it’s a normal file. Other options are 100755, which means it’s an executable file; and 120000, which specifies a symbolic link. The mode is taken from normal UNIX modes but is much less flexible — these three modes are the only ones that are valid for files (blobs) in Git (although other modes are used for directories and submodules).

What are the valid modes for directories (=trees?) and submodules (=commits?), and what does each of them mean?

Evan Aad
  • 5,699
  • 6
  • 25
  • 36

1 Answers1

2

The other valid modes are:

  • 040000 for trees, and
  • 160000 for submodules

These modes tell how the name is to be used. There is no additional meaning attached to them.

j6t
  • 9,150
  • 1
  • 15
  • 35
  • Thanks. Where did you get this information from? – Evan Aad Feb 08 '19 at 16:20
  • 1
    I just know it, because I'm involved in Git development. UTSL :-) – j6t Feb 08 '19 at 16:26
  • FWIW the information is also available [from git's mode canonicalisation](https://github.com/git/git/blob/ab336e8f1c8009c8b1aab8deb592148e69217085/cache.h#L285-L294). As the excerpt nodes, the modes come from POSIX's stat(2) codes, except for submodules which are `S_IFLNK + S_IFDIR` (because [it's a link to an other git directory](https://github.com/git/git/blob/ab336e8f1c8009c8b1aab8deb592148e69217085/cache.h#L63)). Though it should be noted that the canonicalisation will interpret any mode which is not REG, REG+X, LNK, or DIR as a submodule (GITLINK), so git will parse 75483 as submodule. – Masklinn Aug 03 '22 at 19:32