forked from asdf2014/algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
first_commit.sh
executable file
·47 lines (37 loc) · 1.08 KB
/
first_commit.sh
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
#!/usr/bin/env bash
# check git
command -v git >/dev/null 2>&1 || {
echo >&2 "I require git but it's not installed!"; exit 1;
}
# check username
user_name=`git config user.name`
if [[ ${user_name}_x != "_x" ]]; then
echo "Get github's username: ${user_name}."
else
echo "Please set github's username firstly!"
open "https://yuzhouwan.com/posts/30041/#Git-Config"
exit 1
fi
# check SSH
ssh_succ=`ssh -T git@github.com 2>&1 | grep "successfully" | wc -l`
if [[ $(echo "${ssh_succ}" | bc) -eq 1 ]]; then
echo "You've successfully authenticated."
else
echo "Please set SSH to github!"
open "https://yuzhouwan.com/posts/30041/#SSH-%E5%85%8D%E5%AF%86"
exit 1
fi
# build project
mkdir algorithm
cd algorithm
git init
git remote add origin git@github.com:${user_name}/algorithm.git
git remote add upstream git@github.com:asdf2014/algorithm.git
git pull upstream master:master
# build commit
mkdir -p Codes/${user_name}
echo ${user_name} > Codes/${user_name}/README.md
git add .
git commit -m "Add ${user_name}'s first commit"
# push commit
git push upstream master