User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_hooks [2019/02/19 10:54]
rpjday [post-commit]
git_hooks [2019/02/19 11:10] (current)
rpjday [Default hook installation for a new repository]
Line 35: Line 35:
   * Make sure they are marked as executable.   * Make sure they are marked as executable.
-  * Remove the ''​.sample'' ​prefix ​(exact spelling is important).+  * Remove the ''​.sample'' ​suffix ​(exact spelling is important).
 +===== Where hooks are effectively run =====
 +From ''​man githooks'':​
 +Before Git invokes a hook, it changes its working directory to
 +either $GIT_DIR in a bare repository or the root of the working
 +tree in a non-bare repository. An exception are hooks triggered
 +during a push (pre-receive,​ update, post-receive,​ post-update,​
 +push-to-checkout) which are always executed in $GIT_DIR.
 ===== commit-related client-side hooks ===== ===== commit-related client-side hooks =====
Line 235: Line 246:
 There is no sample script provided by Git; you're on your own here. There is no sample script provided by Git; you're on your own here.
 +===== Overriding the default hooks =====
 +==== git init ====
 +When initializing a new repository, the template content used for the new repository comes from one of (in order of precedence):​
 +  * the ''​%%--%%template=<​template directory>''​ option
 +  * the value of the ''​$GIT_TEMPLATE_DIR''​ environment variable
 +  * the ''​init.templateDir''​ configuration option
 +  * the contents of ''/​usr/​share/​git-core/​templates/''​
 +==== git clone ====
 +When cloning a repository, the only way to override the installation of default hooks (and template content) is via the ''​%%--%%template=<​template directory>''​ command-line option.
 +==== During normal operation ====
 +From ''​man git-config'':​
 +    By default Git will look for your hooks in the
 +    $GIT_DIR/​hooks directory. Set this to different path, e.g.
 +    /​etc/​git/​hooks,​ and Git will try to find your hooks in that
 +    directory, e.g.  /​etc/​git/​hooks/​pre-receive instead of in
 +    $GIT_DIR/​hooks/​pre-receive.
 +    The path can be either absolute or relative. A relative
 +    path is taken as relative to the directory where the hooks
 +    are run (see the "​DESCRIPTION"​ section of githooks(5)).
 +    This configuration variable is useful in cases where you’d
 +    like to centrally configure your Git hooks instead of
 +    configuring them on a per-repository basis, or as a more
 +    flexible and centralized alternative to having an
 +    init.templateDir where you’ve changed default hooks.
git_hooks.1550573649.txt.gz · Last modified: 2019/02/19 10:54 by rpjday