git - 防止 Git 更改 pull 权限

标签 git version-control

当我从我的存储库中提取更改时,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 unless umask 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 add sharedRepository = group in [core] section.

这与:

cd /path/to/repo
git config core.sharedRepository group

关于git - 防止 Git 更改 pull 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12733452/

相关文章:

git - 如何为我的新 gitlab 帐户生成新的 ssh-key?

git 下载,而不是克隆获取等

GIT预接收 Hook

git - 什么是适合 TDD 的良好 git 工作流程?

sql-server - 如何将 BIDS 解决方案置于源代码控制之下?

c - 作为文本文件的版本控制?

linux - Git 不添加我的文件,即使我添加了它们

version-control - 如何应对软件文档和软件本身的版本控制?

version-control - 每个 bugfix 与 dev 分支的移植的分离分支

shell - 获取 Subversion 中最近 N 次提交的文件列表