如何制作git checkout文件权限模式是777?

时间:2017-06-18 14:27:43

标签: git

我使用root来运行git,每次结帐时文件权限模式都更改为root 644,这意味着apache无法删除,修改。
然后我决定让GIT签出具有权限777的文件。我知道设置umask 000(默认为022)可以做到这一点,但我不想改变我的centos设置。
怎么做?

3 个答案:

答案 0 :(得分:2)

git config core.sharedRepository 0664。请参阅git help config

PS。我使用模式664,因为它比全开666更安全.Git会自动为目录添加可执行位(从而使模式为775或777)。

答案 1 :(得分:1)

find . -type f -not -name '.git*' | xargs chmod 777
find . -type d -not -name '.git*' | xargs chmod 666

我在结帐后的钩子中使用它,到现在为止似乎没有任何问题。

答案 2 :(得分:0)

Git 2.9 or more, you can do

git add --chmod=+x -- afile
git commit -m "Executable!"

然后,在下一次克隆或结帐时,该文件将是可执行的。

旁注:正确的umask would be 022 (for 755) or 002 for 775。通常不建议使用777。

注意777(即使使用git update-index)没有意义,因为Git itself does not record write: only 644 or 755, spelled 100644 and 100755, with the 100 part meaning "regular file"