在钩子中使用git pull时错误的文件权限 [英] Wrong file permission when using git pull in a hook
问题描述
我已经创建了下面的git钩子来更新我的web应用程序,当新的更改被推送到存储库时
I have created the following git hook to update my web application when new changes are pushed to the repository
#!/bin/sh
#Update the server version to HEAD
echo "Updating webapp..."
unset $(git rev-parse --local-env-vars)
(cd /var/www/webapp && git pull -q)
然而, ,如果我添加新文件,他们会得到错误的权限。它们只能由所有者读取,而不能由组或其他用户读取。但我需要它们让每个人都可读。在本地他们有正确的许可位。即使我从shell手动运行钩子,它也能正常工作。它只在脚本被调用为钩子时不起作用。
However, if I add new files they get the wrong permissions. They are only readable by the owner and not by the group or by other users. But I need them to be readable by everyone. Locally they have the right permission bits. And even when I run the hook manually from the shell, it works correctly. It only doesn't work when the script is called as a hook.
任何想法如何解决这个问题?
Any ideas how to fix that?
PS:我使用git 1.7
PS: I am using git 1.7
推荐答案
Git不存储权限,除了可执行位之外。因此,在结帐时,文件是使用默认权限创建的,这取决于您的 umask 。
Git does not store permissions, apart from the executable bit. So, on checkout, files are created with the default permissions, which depend on your umask.
我想,当你手动调用钩子时,你有一个更自由的umask集合。您可以使用 umask
shell命令覆盖umask。出于您的目的,0022可能没有问题。
I guess, when you are calling the hook manually, you have a more liberal umask set. You can override the umask with the umask
shell command. For your purposes, 0022 is probably fine.
这篇关于在钩子中使用git pull时错误的文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!