问题描述
我克隆了GHC(格拉斯哥Haskell编译器)存储库。为了构建编译器,你需要几个库,它们也都可以用作git库。为了让人们生活得更轻松,GHC黑客们包括一个脚本 sync-all
,这些脚本在执行时会更新所有依赖的存储库。 现在我的问题:我做了一个 git pull $后,如何让git执行
./ sync-all pull
c $ c>自动?我听到有关使用钩子的一些信息,但我不知道,我必须做什么。
post-receive
或 post-update
钩子通常用于这种类型的任务,每次推后执行。
post-receive 和 post-update 钩子在参数中:a post-receive
会同时得到旧的和
缺失的部分是:钩子在哪里执行自己?
博文对此有一些阐述:
确保您的 hook / post-receive
脚本,一旦创建并可执行,就在正确的路径上设置 GIT_WORK_TREE
code> ./ sync-all pull 要在正确的目录中执行(即不是 xxx.git
一个)。
I cloned the GHC (Glasgow Haskell Compiler) repository. In order to build the compiler, you need several libraries, all of them are available as git repositories too. In order to ease ones live, the GHC hackers included a script sync-all
that, when executed, updates all the dependent repositories.
Now to my question: How can I make git execute ./sync-all pull
after I did a git pull
automatically? I heard something about using hooks, but I don't really know, what I have to do.
A post-receive
or post-update
hook is generally used for this kind of task, executed after each push.
The difference between the post-receive and post-update hooks is in the arguments: a post-receive
will get both the old and the new values of all the refs in addition to their names.
The missing piece is: where that hook executes itself?
The blog post "Missing git hooks documentation" from (a great) SO contributor Mark Longair sheds some light on this:
Make sure your hook/post-receive
script, once created and made executable, sets the GIT_WORK_TREE
at the right path, in order for your ./sync-all pull
to be executed in the right directory (i.e. not "xxx.git
" one).
这篇关于如何在git中获取或拉取命令后立即执行命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!