Git在结账时更改我的文件权限 [英] Git changes my file permissions upon checkout

查看:127
本文介绍了Git在结账时更改我的文件权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的工作流程是在本地机器上开发的,将更改提交到中央存储库,然后检查我们需要的存储库的分支。



问题是Git会更改它检出的文件的所有权,甚至是文件权限,具体取决于签出的用户。直接的结果是我们的CSS文件在结账后变得不可读,因为Git会将文件所有权更改为在Webroot中执行Git pull的人。



示例:
$ b


  • 之前> git pull : style.css 拥有 user_a:group_a

  • 之后> git pull style.css 归属于 user_b:user_b



我想将所有权保留为 user_a:group_a 。我不希望每次我的团队对文件进行更改时都必须登录,并将所有权更改回原始配置。



如何其他人处理这个问题吗?你如何处理多个用户使用的存储库。我们的系统上有suphp,无法取消它。 解决方案

Git不会更改文件权限或所有权。只是它(大部分)并不存储它,它不存在于你的回购中,所以它们会变成你的用户拥有的任何东西。就像创建任何文件一样。



Git支持两个权限集:可执行位和可执行位。没有其他的。所有权信息根本不存储。



请参阅 this thread - 如果你想要特定的权限,你需要手动完成。



有一些解决方案建议:您可以使用单独的工具为您完成,使用用户帐户和umask的适当组合来默认设置它们,或者自己写一个git钩子来完成它。



像@ikke在评论中说的,Git并不是一个真正的部署工具,不应该被使用因此。它是一个用于源代码的版本控制系统。


Our workflow is develop on a local machine, commit the changes to a central repository, then check out the branch of that repository that we need.

The problem is that Git changes ownership and even file permissions of the files that it checks out, depending on the user making the checkout. A direct result of this is that our CSS files become unreadable after a checkout, as Git changes the file ownership to the person who did the Git pull in the webroot.

Example:

  • Before git pull: style.css owned by user_a:group_a
  • After git pull: style.css owned by user_b:user_b

I want to keep ownership as user_a:group_a. I don't want to have to log in every time one of my team has made a change to the files, and change the ownership back to the original configuration.

How do other people deal with this? How do you deal with repositories used by multiple users. We have suphp on our system and cannot take it off.

解决方案

Git does not change file permissions or ownership. It's just that it (mostly) doesn't store it either, it doesn't exist in your repo, so they get changed to whatever your user has. Just like with any file creation.

Git supports two permission sets: executable bit on and executable bit off. Nothing else. Ownership information is not stored at all.

See this thread - "If you want specific permissions, you'll need to do it manually."

There are some solutions suggested: you can use a separate tool to do it for you, use a proper combination of user account and umask to set them properly by default or write a git hook yourself to do it. A hook would've to be installed on the user doing the checkout.

Like @ikke said in the comments, Git is not really a deployment tool and should not be used as such. It is a version control system for source code.

这篇关于Git在结账时更改我的文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆