20

This is related to another question I recently asked about storing a non-bare repository in Dropbox for easy movement between computers, so it may be helpful to read that question for background.

The gist is that the fileMode keeps reporting a diff for some number of files. I can't find a way to reproduce it consistently, but it happens frequently. What I've noticed is that the file, which has 644 permissions on both machines often reports a diff from 755 on one of the machines. This makes me think that Git believes the executable bit is set, but I can't figure out whether I can actually see how Git has that bit set.

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
Rob Wilkerson
  • 40,476
  • 42
  • 137
  • 192
  • Just to make sure I’m reading this correctly: The files on disk are always `644`, but the files in the commits are sometimes `755`? What does `git ls-tree` or `git ls-files -s` say? That will tell you the numbers git has recorded. – Josh Lee Sep 29 '10 at 18:54
  • They say that the bit is unset. The files themselves say 644, but indicate a change that was never made. You did answer the question though. It looks like `git ls-files` is the answer to displaying the executable bit's status. If you'll change your comment to an answer, I'll mark it as such. – Rob Wilkerson Sep 29 '10 at 21:55

2 Answers2

36

To see what git actually thinks about your files in commits and the index, use git ls-tree <tree> and git ls-files -s <path> respectively.

By the way, it seems that git only looks at the executable bit, and assumes 644 for everything else. Look at create_ce_mode in cache.h if you want to try debugging this weird issue.

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
  • 2
    "if you want to try debugging this weird issue"—there's nothing to debug: this is by design. Git's maintainer [says](http://git.661346.n2.nabble.com/why-not-preserve-file-permissions-td1619926.html#a1620446): "…git used to record the full (mode & 0777) for blobs… it had a very unpleasant side effect that the resulting tree depended on user's umasks… one person records a blob with mode 664 and the next person who modifies the file would record with mode 644, and it made it very hard to keep track of meaningful changes… This issue was fixed long time ago with commit e447947 [on] 2005-04-16." – ChrisGPT was on strike Apr 01 '19 at 18:10
0

Use gitk as follows

$ gitk path/to/repository/file

In the opened window, under dashed line you can see six digits. The last three are the file permissions.

...
------------------------------- path/to/repository/file -------------------------
index a5e14048..08ce8948 100644
...

In the example above 6 digits are 100644 and file permission is 644

Levon
  • 10,408
  • 4
  • 47
  • 42