-
Notifications
You must be signed in to change notification settings - Fork 1
/
new_repo
executable file
·41 lines (34 loc) · 1.08 KB
/
new_repo
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
#! /bin/sh
## new_repo
## A simple script to automate creation of Git repository on a private remote
## host such as a VPS account.
## Configuration
# Remote user you will connect as.
REMOTE_USER="user"
# The IP address you will SSH / SCP to.
REMOTE_HOST="123.123.123.123"
# The remote path you wish to store your .git repositories in.
REMOTE_REPO_PATH="/path/to/repos/"
test -f ${HOME}/.new_repo && . ${HOME}/.new_repo
## For basic usage you should not need to edit anything below this line #######
PWD=`pwd`
if [ -d $1/.git ]; then
echo "EXITING: Local git repository '$1' already exists, no changes made."
exit 0
else
test -d $1 || mkdir $1
cd $1
git init
test -f .gitignore || cp .git/info/exclude .gitignore
git add .
git commit -m "Initial repository creation"
cd ..
git clone --bare $1/.git $1.git
echo "** Copying new repository $1.git to $REMOTE_HOST:$REMOTE_REPO_PATH"
scp -r $1.git $REMOTE_USER@$REMOTE_HOST:$REMOTE_REPO_PATH
rm -rf $1.git
rm -rf $1
echo "** Cloning locally at $PWD/$1"
git clone $REMOTE_USER@$REMOTE_HOST:$REMOTE_REPO_PATH$1.git
fi
exit 0