在 git 中显示索引文件的权限 [英] Show the permission of a indexed file in git
问题描述
这与我最近问的关于将非裸存储库存储在Dropbox 用于在计算机之间轻松移动,因此阅读该问题的背景可能会有所帮助.
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.
要点是 fileMode
不断报告一些文件的差异.我找不到一种方法来始终如一地重现它,但它经常发生.我注意到的是,在两台机器上都有 644 权限的文件经常报告与其中一台机器上的 755 不同.这让我认为 Git 相信可执行位已设置,但我不知道我是否真的可以看到 Git 是如何设置该位的.
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.
推荐答案
要查看 git 实际上对提交和索引中的文件有何看法,请使用 git ls-tree
和 git ls-files -s
分别.
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.
顺便说一下,git 似乎只查看可执行位,并假设 644
用于其他所有内容.查看 create_ce_mode in cache.h 如果你想尝试调试这个奇怪的问题.
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.
这篇关于在 git 中显示索引文件的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!