在 Git 中切换分支时文件权限重置
我在一个与我的用户具有不同 Linux 所有者的文件夹上创建了一个 Git 存储库。直到很久以后,我才将组权限设置为写入,以便我的用户可以进行更改并提交到 Git。但是,每当我从分支切换到主分支时,所有组写入权限都会丢失。
我尝试切换到 master 分支,并使用 root 用户使我所在组的所有文件都可写。但是当我切换到不同的分支时,所有组写权限都会再次丢失。
I created a Git repository on a folder that had a different Linux owner than my user. It wasn't until much later that I set the group permissions to write so that my user could make changes and commits to Git. However, whenever I switch from a branch to master, all the group write permissions are lost.
I've tried switching to the master branch, and using the root user to make all files write-enabled for the group I'm in. But when I switch to a different branch, all the group write permissions are lost again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为这是 git 特定的,git 只会使用当前组和 umask 来签出文件,因此如果您希望您的工作树是一个特定组,并且该组可写,您应该使用 newgrp< /code> 登录到所需的组或在工作树上递归设置组和 setgid 位,并确保您的 umask 排除组可写位(例如 0002)。
I don't think that this is git specific, git will just use the current group and umask for checking out files so if you want your working tree to be a specific group an writable by that group you should either use
newgrp
to log in to the required group or recursively set the group and setgid bit on the working tree and ensure that your umask excludes the group writable bit (e.g. 0002).Git 不跟踪权限(可执行标志除外)。因此,请确保当前用户的 umask 设置为不从文件中删除组可写标志。它通常设置为
022
,在您的情况下应设置为002
。man umask
了解更多详细信息。Git does not track permissions (except for the executable flag). So make sure that the
umask
of your current user is set to not remove the group-writable flag from files. It is normally set to022
, in your case it should be set to002
.man umask
for more details.