blob: 9c3678a0d27b2cb41e429f18ece422cb75be8497 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# How to create a git mirror on github
## Repository on github
Make sure to create an empty repository on github and have an access from the VPS to it (token or ssh).
```sh
# 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.
```
## 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 :
```sh
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.
|