-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgit-remote-clone
executable file
·39 lines (29 loc) · 987 Bytes
/
git-remote-clone
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
#!/usr/bin/env bash
#
# Imprefect script to create a clone of the local repository on a remote server that
# is accessible by ssh.
#
if [ "$#" -ne 1 ] ; then
echo "Expected host:path" >&2
exit -1
fi
set -e
set -u
X="$1"
arr=(`echo $X | tr ':' ' '`)
dest=${arr[0]}
remote_path=${arr[1]}
if [ -z "$dest" ] ; then
echo "Destination not specified" >&2
exit -1
fi
if [ -z "$remote_path" ] ; then
echo "Path on destination not specified" >&2
exit -1
fi
branch=master
ssh -t ${dest} "mkdir -p ${remote_path} && cd ${remote_path} && git init" || exit -1
ssh -t ${dest} "cd ${remote_path} && git config receive.denyCurrentBranch no" || exit -1
ssh -t ${dest} "cd ${remote_path} && git init && touch nothing && git -c user.name=empty -c user.email=empty@empty add nothing" || exit -1
ssh -t ${dest} "cd ${remote_path} && git -c user.name=empty -c user.email=empty@empty commit -m nothing --author='nothing <nothing@nothing.com>'" || exit -1
git-remote-push "$@"