aboutsummaryrefslogtreecommitdiff
path: root/git/git-mirror.md
diff options
context:
space:
mode:
Diffstat (limited to 'git/git-mirror.md')
-rw-r--r--git/git-mirror.md36
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
```