当我从我的存储库中提取更改时,Git 会更改文件权限(实际上,他会更改组 write
权限)。
如果我是对的,Git 应该只跟踪可执行位,无论如何都可以通过将 core.filemode
设置为 false 来删除。
但是,尽管文件模式设置为 false(在本地、全局和用户中),当我 pull 时,write
权限不断变化。
我可以使用 git-hooks 来重置正确的 chmod,但这是一些开销,如果有一种方法可以让 git 完全忽略文件模式更改,我更愿意。
有人知道如何实现吗?
最佳答案
可能在这里有帮助的一个配置设置是 core.sharedRepository
,在博文“Preserving Group Write on Git Objects in a Collaborative Repository”中介绍:
The solution turned out to be fairly straightforward.
In the file.git/config
, I added a line that read: "sharedRepository = group
", like so:[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true sharedRepository = group
Thereafter, new files in
.git/objects
were created with the proper permissions for group write.
(However, note that new files are group-owned by the primary group of the user account via which the push was received. If the users collaborating on the project have different primary groups, and if those users do not share membership in that set of groups, you may still run into problems.)
确保 umask
的值:
Example:
0660
will make the repo read/write-able for the owner and group, but inaccessible to others (equivalent to group unlessumask
is e.g.0022
).
2022(10 年后),SyedAsadRazaDevops添加 the comments :
In Ubuntu (Linux), just go to the project repo and run this command
nano .git/config
and addsharedRepository = group
in[core]
section.
这与:
cd /path/to/repo
git config core.sharedRepository group
关于git - 防止 Git 更改 pull 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12733452/