From 76631f1123b785f3cff38720b41055828ddef123 Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Thu, 30 Jan 2025 23:29:20 +0100 Subject: Improving git-mirror.md --- git/git-mirror.md | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/git/git-mirror.md b/git/git-mirror.md index ba26f85..9c3678a 100644 --- a/git/git-mirror.md +++ b/git/git-mirror.md @@ -1,32 +1,40 @@ -# How to create a git mirror +# How to create a git mirror on github -## Hook +## Repository on github -On the server, within the bare git repository, create a post-receive hook with the following content : +Make sure to create an empty repository on github and have an access from the VPS to it (token or ssh). ```sh -#!/usr/bin/env bash -# Push changes to GitHub -git push --mirror github +# 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. ``` -And make it executable : +## Hook + +On the server, within the bare git repository, create a `post-receive` hook and make it executable : ```sh +touch /hooks/post-receive chmod +x /hooks/post-receive ``` +Add a simple git push in the hook : + +```sh +cat << EOF > /hooks/post-receive +#!/bin/bash +# Push changes to GitHub +git push --mirror github +EOF +``` + ## 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 +```sh git remote add github git@github.com:/.git ``` -- cgit v1.2.3