In Git, how can I write the current commit hash to a file in the same commit

I would recommend doing something similar to what you have in mind: placing the SHA1 in an untracked file, generated as part of the build/installation/deployment process. It’s obviously easy to do (git rev-parse HEAD > filename or perhaps git describe [–tags] > filename), and it avoids doing anything crazy like ending up with a file … Read more

Is there any git hook for pull?

The githooks man page is a complete list of hooks. If it’s not on there, it doesn’t exist. That said, there is a post-merge hook, and all pulls include a merge, though not all merges are pulls. It’s run after merges, and can’t affect the outcome. It never gets executed if there were conflicts; you’d … Read more

Putting Git hooks into a repository

I generally agree with Scy, with a couple of additional suggestions, enough that it’s worth a separate answer. First, you should write a script which creates the appropriate symlinks, especially if these hooks are about enforcing policy or creating useful notifications. People will be much more likely to use the hooks if they can just … Read more

Best way to allow plugins for a PHP application

You could use an Observer pattern. A simple functional way to accomplish this: <?php /** Plugin system **/ $listeners = array(); /* Create an entry point for plugins */ function hook() { global $listeners; $num_args = func_num_args(); $args = func_get_args(); if($num_args < 2) trigger_error(“Insufficient arguments”, E_USER_ERROR); // Hook name should always be first argument $hook_name … Read more

Applying a git post-commit hook to all current and future repositories

As of Git 1.7.1, you can set init.templatedir in your gitconfig to tell Git where to look for templates. Set it like this: git config –global init.templatedir ‘~/.git_template’ Afterward, new repositories you create or clone will use this directory for templates. Place the hooks you want in ~/.git_template/hooks. Existing repositories can be reinitialized with the … Read more

tech