如何找出使用git检出文件时导致文件权限更改的原因? [英] How to find out what causes file permissions to change when checking out files with git?

查看:120
本文介绍了如何找出使用git检出文件时导致文件权限更改的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 #!/ bin / sh $在将文件推送到我们的服务器后,将执行以下post-receive hook: b $ b export GIT_WORK_TREE = / home / user / www / 
git checkout -f

然而,文件在结帐时会得到一个非常奇怪的 600 权限和 700 文件夹。这不是我所期望的(在我们的其他服务器上,我们得到 644 755 )。从这个线程我明白,git不设置权限,所以git不是怪罪。我的问题是:什么是?我怎样才能找出造成这个问题的原因?



我已经通过在结帐时运行额外的脚本来解决这个问题,暂时解决了这个问题,但我有兴趣解决问题的根源。



我使用gitolite来管理存储库,但我怀疑这是原因。但是,我很高兴知道我可以在哪里开始,因为在这一点上我不确定如何调查。

根据最初的答案,我已经查看了服务器上的umask设置。 git 用户(这是用户上传文件的用户),umask设置为0002.这在以下练习中得到了确认:

  git @ server:〜$ umask 
0002
git @ server:〜$ touch newfile
git @ server:〜$ ls -la newfile
-rw-rw-r-- 1 git git 0 Aug 5 10:46 newfile

其他详细信息:


  • Linux在服务器端和开发端使用

  • In本地repo,权限为755和644

  • filemode在.git / config中设置为true

然而,文件获得非常奇怪的600个权限,并且在结账时文件夹700。


它看起来像你的shell有一个限制性的umask设置,可能 umask 0177



< blockquote>

从这个线程我明白,git不设置权限,所以git不是怪。




不,这是您的shell的 umask 设置。



< blockquote>

我的问题是:[...] [如何]我可以找出造成这个问题的原因?

运行 umask ,它会告诉你什么是你当前的设置。它就像是 0177 或类似的。
如果您想了解
,您需要查看 / bin / sh 使用的rc文件,
最可能是 .profile .bashrc 以及其他来源文件。



您可以限制 umask 设置,但在脚本中覆盖它们,方法是添加 umask 建议使用@VonC。


After pushing files to our server, the following post-receive hook is executed:

#!/bin/sh
export GIT_WORK_TREE=/home/user/www/
git checkout -f

However, files get a very odd 600 permission, and folders 700 upon checkout. This is not what I expect (on our other servers we get 644 and 755). From this thread I understand that git does not set permissions, so git is not to blame. My question is: what is? How can I figure out what the cause is of this issue?

I have already temporarily solved it by running an extra script upon checkout to fix the permissions, but I am interested in solving the root cause.

I'm using gitolite to manage the repositories, but I doubt that is the cause. But again, I'm happy to learn where I can start because at this point I'm not sure how to investigate this.

As per the initial answers I have looked into the umask settings on the server. The git user (that's the user used to upload the files), the umask setting is 0002. This is confirmed in the following exercise:

git@server:~$ umask
0002
git@server:~$ touch newfile
git@server:~$ ls -la newfile
-rw-rw-r-- 1 git git 0 Aug  5 10:46 newfile

Additional details:

  • Linux used on both server side and development side
  • In the local repo, permissions are 755 and 644
  • filemode is set to true in .git/config

解决方案

However, files get a very odd 600 permission, and folders 700 upon checkout.

It looks like your shell has a restrictive umask setting, possibly umask 0177.

From this thread I understand that git does not set permissions, so git is not to blame.

No, it is the umask setting of your shell.

My question is: [...] [how] can I figure out what the cause is of this issue?

Run umask, it will tell you what is your current setting. It's like to be 0177 or similar. If you want to know why, you need to look through the rc files used by /bin/sh, most probably .profile or .bashrc, and other files sourced.

You can have very restrictive umask settings but override them in your script, by adding a umask line as @VonC suggested.

这篇关于如何找出使用git检出文件时导致文件权限更改的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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