将新文件夹/文件推送到共享库时,Git将创建模式设置为100664 [英] Git set create mode to 100664 when pushing new folder/files to shared repo

查看:261
本文介绍了将新文件夹/文件推送到共享库时,Git将创建模式设置为100664的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的同事有一个共享的网站回购。我们都在Windows 7 64位推向Ubuntu 10.04。以下是我们的设置,以防有问题。



local-> hub->网站



我们推到集线器,这是一个裸仓库,然后在集线器的后续更新挂钩到网站仓库,并将更改从集线器拖到网站。这是因为该网站是活的,并始终签出,不能推送到。



当我在我的本地和我提交一个新的文件夹/文件它以100644的创建模式声明如下

  $ git commit -a -mtesting permissions
[ master 865b809]测试权限
1个文件已更改,1个插入(+),0个删除( - )
创建模式100644 test.php

当我将这些更改推送到repo时,它会创建文件夹755和文件644,当我需要它们为775和664时。只要我只是编辑文件权限至少保持不变。唯一的问题在于创建。



在共享库上我们有 core.sharedrepository = 0660 它会根据我的需要设置权限。我们的 .bashrc 中的 umask 设置为002。



这是我的本地配置

  [core] 
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly

看起来好像我们的本地用户正在确定权限并忽略共享库中的设置。



编辑



集线器配置

$ b如何获得创建模式为100664
$ b

  [core] 
repositoryformatversion = 0
filemode = true
bare = true
sharedrepository = 0660
[receive]
denyNonFastforwards = true

网站配置


$ b $

  [core] 
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
sharedrepository = 1
[receive]
denyNonFastforwards = true



EDIT2



正如下面的Kalle Pokki在她的评论中指出的那样。这个问题是,当使用GIT并推送它非交互式运行,所以我的umask设置不起作用。我更新了我的回购版更新后的设置,以便每当有人推送时,将umask设置为 0002 解决方案

据我所知,git不会在所需级别存储文件权限。拥有644或664文件完全取决于umask。


$ b $ core.sharedrepository只处理git数据库的文件权限,而不处理存储在存储库中的文件权限。


因为你已经有了更新后的钩子去检查Web服务器中的存储库,所以我建议在那里添加一个chmod脚本。类似于

  find / path / to / website -t​​ype d | xargs chmod 775 
find / path / to / website -t​​ype f | xargs chmod 664

编辑:我很自信你的ssh / git服务器与你有不同的umask有交互式登录时。也许你应该在更新后的钩子开始时明确地设置umask。请参阅以下内容,其中tmp分支中的附加文件'1'不存在于master分支中:

  $ umask 0022 
$ git checkout tmp
转换到分支'tmp'
$ ls -l 1
-rw-r - r-- 1 kp kp 5 2013-01 -15 15:53 1
$ git checkout master
转换到分支'master'
$ umask 0002
$ git checkout tmp
转换到分支'tmp'
$ ls -l 1
-rw-rw-r-- 1 kp kp 5 2013-01-15 15:53 1


Me and my colleagues have a shared Website repo. We are all on Windows 7 64 bit pushing to Ubuntu 10.04. Below is our setup in case this is in question.

local->hub->website

We push to the hub, which is a bare repo, then with a post-update hook in the hub cds to the website repo and pulls the changes from the hub to the website. This is done because the website is live and always checked out and can't be pushed to.

When I'm on my local and I commit a new folder/file it states the below with the create mode of 100644

$ git commit -a -m "testing permissions"
[master 865b809] testing permissions
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test.php

When I push these changes to the repo it creates the folders as 755 and files as 644 when I need them to be 775 and 664. As long as I'm only editing files the permissions at least stay the same. The only problem is on creation.

On the shared repo we have core.sharedrepository = 0660 which I thought meant it would set permissions as I needed. Also our umask in our .bashrc is set to 002.

Here is my local config

[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly

It seems as though our local is determining the permissions and ignoring what is setup on our shared repo. How can I get the create mode to be 100664.

EDIT

Hub config

[core]
repositoryformatversion = 0
filemode = true
bare = true
sharedrepository = 0660
[receive]
denyNonFastforwards = true

Website config

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
sharedrepository = 1
[receive]
denyNonFastforwards = true

EDIT2

As Kalle Pokki below pointed out in her comments. This issue is that when using GIT and pushing it is running non-interactively so my umask setup doesn't work. I've updated my post-update for my repo to set the umask to 0002 everytime anyone pushes.

解决方案

From what I can tell, git doesn't store file permissions at the level you want. Having 644 or 664 files depends purely on umask.

core.sharedrepository only deals with the file permissions of the git database, not the permissions of the files stored in the repository.

As you already have the post-update hook to check out the repository in the web server, I'd suggest to add a chmod script there. Something like

find /path/to/website -type d | xargs chmod 775
find /path/to/website -type f | xargs chmod 664

EDIT: I'm quite confident your ssh/git server has different umask than what you have when logged in interactively. Perhaps you should set the umask explicitly at the beginning of the post-update hook. See the following where I have the additional file '1' in the tmp branch that doesn't exist in the master branch:

$ umask 0022
$ git checkout tmp
Switched to branch 'tmp'
$ ls -l 1
-rw-r--r-- 1 kp kp 5 2013-01-15 15:53 1
$ git checkout master
Switched to branch 'master'
$ umask 0002
$ git checkout tmp
Switched to branch 'tmp'
$ ls -l 1
-rw-rw-r-- 1 kp kp 5 2013-01-15 15:53 1

这篇关于将新文件夹/文件推送到共享库时,Git将创建模式设置为100664的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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