commit a1cc80994358bf88d0301e8348a2411bf50814b8
parent 5a036ea6927bc6c309242f7e386a0a309ee67cb1
Author: pyratebeard <root@pyratebeard.net>
Date: Fri, 11 Nov 2022 20:40:15 +0000
what_the_hook
Diffstat:
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/entry/what_the_hook.md b/entry/what_the_hook.md
@@ -6,7 +6,6 @@ For note taking I make use of the [VimWiki](TK){target="_blank" rel="noreferrer"
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.
@@ -42,3 +41,32 @@ In the end I used a command in my ~/.vimrc
```
set :Gac git commit -a -m "updates"
```
+
+Now as soon as I have finished updating my wiki I can incant
+```
+:Gac
+```
+
+and the updates will be committed and pushed, albeit with a generic commit message.
+
+Once the changes are pushed to my git server they hit another hook, `post-receive`.
+```
+#!/bin/sh
+ssh wikiserver "cd /grimoire ; git pull"
+```
+
+As soon as the remote bare repo receives any updates the hook will perform a `git pull` of my wiki on the server I host it on, causing my Gollum page to be updated instantly.
+
+The finally thing I have done is to change the hooks directory in my local repo. With the default dir, ".git/hooks", nothing can be tracked by git.
+
+Instead I created a directory in the repo, ".githooks" and put my `post-commit` hook there. This way it can be tracked in the repo.
+
+For git to know where the hooks are update the config
+```
+git config core.hooksPath .githooks
+```
+*this option was introduced in got v2.9, so make sure you have that version or higher*
+
+As far as I know there is no way to track hooks in a remote bare repo. If you know of a way I would be interested to hear about it.
+
+Who needs a convoluted CI/CD pipeline when a couple of one line scripts will do. Hopefully typing `:Gac` is easy enough for me to do that I will be able to keep my wiki up to date.