blob: 15aa8c4a95a42e444ccf185b9fd929eed616bb6c (
plain) (
blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#! /usr/bin/env bash
# Usage examples
#
# Init public repository and mirror it to github.
# ./init-git-repo.sh --public --mirror repo.git
public=0
mirror=0
repo=""
while [[ $# -gt 0 ]]; do
case $1 in
-p|--public)
public=1
shift
;;
-m|--mirror)
mirror=1
shift
;;
-*|--*)
echo "Unknown option $1" 1>&2
exit 1
;;
*)
repo=$1
shift
;;
esac
done
if [ -z $repo ]; then
echo "Provide repository name!" 1>&2
exit 1
fi
mkdir $repo
cd $repo
git init --bare
if [ $public -eq 1 ]; then
touch git-daemon-export-ok
fi
if [ $mirror -eq 1 ]; then
git remote add --mirror github git@github.com:ilvokhin/$repo
cat > hooks/post-receive <<EOF
#! /bin/sh
git push --quiet github &
EOF
chmod +x hooks/post-receive
fi
cd ..
|