diff options
author | clyhtsuriva <aimeric@adjutor.xyz> | 2025-01-30 23:29:20 +0100 |
---|---|---|
committer | clyhtsuriva <aimeric@adjutor.xyz> | 2025-01-30 23:29:20 +0100 |
commit | 76631f1123b785f3cff38720b41055828ddef123 (patch) | |
tree | eb74bbe78d9843bf5365b089fbfa57ce159dc3a5 | |
parent | 8c7781c2e34aedfa64eab5e4698ec174432564fe (diff) |
Improving git-mirror.md
-rw-r--r-- | git/git-mirror.md | 36 |
1 files 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 <user>! 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 <repository path>/hooks/post-receive chmod +x <repository path>/hooks/post-receive ``` +Add a simple git push in the hook : + +```sh +cat << EOF > <repository path>/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 <user>! You've successfully authenticated, but GitHub does not provide shell access. - -# Add the remote github repo +```sh git remote add github git@github.com:<user>/<repository name>.git ``` |