Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用git/hooks进行后期签出_Git_Shell_Post Commit - Fatal编程技术网

使用git/hooks进行后期签出

使用git/hooks进行后期签出,git,shell,post-commit,Git,Shell,Post Commit,由于git总是弄乱文件权限设置,我想在git中添加一个shell脚本,以便在签出后更改权限。所以我想在结账后添加以下内容 #!/bin/sh find . -type f -print0 | xargs -0 chmod 664 find . -type d -print0 | xargs -0 chmod 775 但是git post签出是通过使用在.git/hooks/so中实现的。操作员将只查看该文件夹,或者git是否知道从主项目目录获取该文件夹以开始搜索 我有点困惑的一个原因是,如果

由于git总是弄乱文件权限设置,我想在git中添加一个shell脚本,以便在签出后更改权限。所以我想在结账后添加以下内容

#!/bin/sh

find . -type f -print0 | xargs -0 chmod 664
find . -type d -print0 | xargs -0 chmod 775
但是git post签出是通过使用在.git/hooks/so中实现的。操作员将只查看该文件夹,或者git是否知道从主项目目录获取该文件夹以开始搜索

我有点困惑的一个原因是,如果在
.git/hooks
上执行git状态,您会得到以下结果:

% git status
fatal: This operation must be run in a work tree

每个钩子都以Git存储库的根目录(即包含
.Git
的目录)作为其工作目录运行。您的脚本应该可以工作。

注意
find.
降级到
.git
本身(尽管这里给出的chmod命令应该是无害的)。但是:git不应该“弄乱文件权限设置”:签出的文件应该具有umask指示的模式,并且执行位存储在repo中。如果您的umask是002(组写入),则目录应该已经是775,文件应该已经是664。回购中的对象应具有基于
core.sharedepository
的模式;明白了。如果我想追踪他们,我怎么能把这些记录回回购协议?