From 8c7781c2e34aedfa64eab5e4698ec174432564fe Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Thu, 30 Jan 2025 22:47:12 +0100 Subject: Add page about git mirroring w/ hooks --- README.md | 1 + git/git-mirror.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 git/git-mirror.md diff --git a/README.md b/README.md index 36c0497..c610861 100644 --- a/README.md +++ b/README.md @@ -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 /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 ! You've successfully authenticated, but GitHub does not provide shell access. + +# Add the remote github repo +git remote add github git@github.com:/.git +``` + +## Validate + +Now you should be able to make a simple push to the git server and see github updated as well. -- cgit v1.2.3