Geo*_*let 28 git hook git-clone
根据手册,post-checkout
钩子在a git checkout
(正如预期)之后运行,但也在a之后运行git clone
(除非你通过--no-checkout
).
很好,现在,考虑以下因素:
git clone
--template
被复制为不可执行,因此之后不执行git clone
一个post-checkout
钩子似乎不可能在一个之后被执行git clone
.尽管如此,http: //git-scm.com/docs/githooks上的githooks
手册页明确说明了一种避免执行的方法,并且在执行时也传递了参数,这表明可以执行自定义钩子经过.git-clone
那么,怎么可能呢?我显然在这里遗漏了一些东西.
结果
Cas*_*bel 15
我想你可以进行自定义安装 - 重命名钩子.../share/git-core/templates/hooks
以删除.sample
后缀.
您还可以将一个充满符号链接的模板目录创建到存储库内的钩子目录(例如post-checkout -> ../../hooks/post-checkout
).然后,如果克隆的repo包含该特定的钩子,它就会被执行.
不过,你说得对,在大多数情况下都不会发生.
编辑:我刚测试了它,该--template
选项似乎确实保留了权限,因此这是一种更直接的方式来实现它.你看到什么表明它剥离了那一点?
关于版本的最终决定权:你正在网上查看更新版本的git而不是你正在使用的文档.这个功能是在dfa7a6c中添加的(克隆:签出时运行post-checkout hook); git describe说直到v1.6.2-rc2才包括这个.
Gre*_*con 12
当混帐初始化运行,例如挂钩极少数被复制到
hooks
新的存储库的目录中,但默认情况下它们都被禁止.要启用挂钩,请通过删除其.sample
后缀来重命名它.
这个初始化发生作为创建克隆,注意调用的一部分init_db
在builtin-clone.c
.
例如:
$ cat /tmp/my-git-template/hooks/post-checkout #! /bin/bash echo "Hello from $0" $ git clone --template=/tmp/my-git-template file:///tmp/repo.git my-clone Initialized empty Git repository in /tmp/my-clone/.git/ remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done. Hello from .git/hooks/post-checkout
归档时间: |
|
查看次数: |
24666 次 |
最近记录: |