pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

commit f83dd80ee69cd6dadfddaed5684d49a8d4b68d7d
parent 57c3840cd0ec9435dada5cf18690a5a57c3c54c2
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 10 Nov 2022 13:19:23 +0000

what_the_hook

Diffstat:
Aentry/what_the_hook.md | 35+++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+), 0 deletions(-)

diff --git a/entry/what_the_hook.md b/entry/what_the_hook.md @@ -0,0 +1,35 @@ +Git [hooks](TK){target="_blank" rel="noreferrer"} are often overlooked or underused. They can be very useful, and even used as a rudimentary CI/CD workflow. + +While these tips can work for any repo, this could be viewed as an expansion on my [tech_grimoire](20220525-tech_grimoire.html){target="_blank" rel="noreferrer"} post. + +For note taking I make use of the [VimWiki](TK){target="_blank" rel="noreferrer"} plugin to Vim. My wiki directory is a git repository, which is then cloned on to one of my servers and using [Gollum](TK){target="_blank" rel="noreferrer"}, available as a website. + +This has worked well for years, but one thing I have not been good at is committing and pushing changes straight away. In order to improve my workflow I make use of two git hooks, one in the local repo and one in the remote bare repo. + +### hook me up +Git hooks are scripts which can be run at various times in a git workflow. When they run is based on the name of the script. + +If you look in the ".git/hooks" directory of a repo you should see some sample scripts. + +``` +──── ─ ls -1 .git/hooks +applypatch-msg.sample +commit-msg.sample +fsmonitor-watchman.sample +post-update.sample +pre-applypatch.sample +pre-commit.sample +pre-merge-commit.sample +pre-push.sample +pre-rebase.sample +pre-receive.sample +prepare-commit-msg.sample +push-to-checkout.sample +update.sample +``` + +For my wiki I make of the `post-commit` hook. +``` +#!/bin/sh +git push origin master +```