diff options
author | clyhtsuriva <aimeric@adjutor.xyz> | 2025-01-30 22:47:12 +0100 |
---|---|---|
committer | clyhtsuriva <aimeric@adjutor.xyz> | 2025-01-30 22:47:12 +0100 |
commit | 8c7781c2e34aedfa64eab5e4698ec174432564fe (patch) | |
tree | 9139ed155e1defbfc0a79737d137e60e0c25453e | |
parent | 62ed6b73c8eb34dc5ad42def2eba9c273739b6df (diff) |
Add page about git mirroring w/ hooks
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | git/git-mirror.md | 35 |
2 files changed, 36 insertions, 0 deletions
@@ -1,4 +1,5 @@ # Homelab wiki This wiki serves as a documentation and reminder for myself when administrating my homelab. + Applying anything you see in here, on your own setup, is at your own risk. diff --git a/git/git-mirror.md b/git/git-mirror.md new file mode 100644 index 0000000..ba26f85 --- /dev/null +++ b/git/git-mirror.md @@ -0,0 +1,35 @@ +# How to create a git mirror + +## Hook + +On the server, within the bare git repository, create a post-receive hook with the following content : + +```sh +#!/usr/bin/env bash +# Push changes to GitHub +git push --mirror github +``` + +And make it executable : + +```sh +chmod +x <repository path>/hooks/post-receive +``` + +## Remote + +Configure the remote github repo : + +``` +# Making sure ssh works with the user, +# else create an ssh key and add it on github +ssh -T git@github.com +# > Hi <user>! You've successfully authenticated, but GitHub does not provide shell access. + +# Add the remote github repo +git remote add github git@github.com:<user>/<repository name>.git +``` + +## Validate + +Now you should be able to make a simple push to the git server and see github updated as well. |