forked from rainsome/myutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkbaregitrepo
executable file
·68 lines (49 loc) · 1.2 KB
/
mkbaregitrepo
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
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
INITIAL="INITIAL";
GITIGNORE=~/bin/gitignore;
WD=$(pwd)
Usage(){
echo -e "Usage: \n $0 <git repo name1> [<git repo name2> ...]\n";
}
createbaregitrepo(){
REPONAME="${1}.git";
mkdir "${REPONAME}";
(
cd "${REPONAME}" && git init --bare ;
)
TMPDIR=$(mktemp -d);
pushd . > /dev/null 2>&1;
cd "${TMPDIR}";
git init;
if [ -f $GITIGNORE ]
then
cp $GITIGNORE .gitignore
git add .gitignore
git commit -am "Initial commit.And add gitignore";
else
echo "Initial repo ${1}" > $INITIAL;
git add $INITIAL;
git commit -am "Initial commit";
fi
git remote add origin "${WD}/${REPONAME}"
git push -vv origin master:master
popd > /dev/null 2>&1;
# git clone --bare $TMPDIR "${1}.git";
echo "Finished Create ${1}.git";
rm -rf $TMPDIR;
}
if [ $# -lt 1 ]
then
Usage;
exit 5;
fi
for repo in "$@"
do
#echo "Repo : $repo"
if [ -e "${repo}.git" ]
then
echo "ERR:${repo}.git IS EXISTS.";
continue;
fi
createbaregitrepo $repo;
done