How can I automatically deploy my app after a git push ( GitHub and node.js)?

Example in PHP: Navigate to github into your github repository add click “Admin” click tab ‘Service Hooks’ => ‘WebHook URLs’ and add http://your-domain-name/git_test.php then create git_test.php <?php try { $payload = json_decode($_REQUEST[‘payload’]); } catch(Exception $e) { exit(0); } //log the request file_put_contents(‘logs/github.txt’, print_r($payload, TRUE), FILE_APPEND); if ($payload->ref === ‘refs/heads/master’) { // path to your site … Read more

Skip Git commit hooks

Maybe (from git commit man page): git commit –no-verify -m “commit message” ^^^^^^^^^^^ -n –no-verify This option bypasses the pre-commit and commit-msg hooks. See also githooks(5). As commented by Blaise, -n can have a different role for certain commands. For instance, git push -n is actually a dry-run push. Only git push –no-verify would skip … Read more

Make Git automatically remove trailing white space before committing

Those settings (core.whitespace and apply.whitespace) are not there to remove trailing whitespace but to: core.whitespace: detect them, and raise errors apply.whitespace: and strip them, but only during patch, not “always automatically” I believe the git hook pre-commit would do a better job for that (includes removing trailing whitespace) Note that at any given time you … 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

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

Can Git hook scripts be managed along with the repository?

In Git 2.9, the configuration option core.hooksPath specifies a custom hooks directory. Move your hooks to a hooks tracked directory in your repository. Then, configure each instance of the repository to use the tracked hooks instead of $GIT_DIR/hooks: git config core.hooksPath hooks In general, the path may be absolute, or relative to the directory where … Read more

Deploy a project using Git push

I found this script on this site and it seems to work quite well. Copy over your .git directory to your web server On your local copy, modify your .git/config file and add your web server as a remote: [remote “production”] url = username@webserver:/path/to/htdocs/.git On the server, replace .git/hooks/post-update with this file (in the answer … Read more