-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgitcommit.sh
executable file
·60 lines (50 loc) · 949 Bytes
/
gitcommit.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
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
function todir() {
pwd
}
function pull() {
todir
echo "git pull"
git pull
}
function forcepull() {
todir
echo "git fetch --all && git reset --hard origin/master && git pull"
git fetch --all && git reset --hard origin/master && git pull
}
# shellcheck disable=SC2120
function gitpush() {
commit=""
if [ ! -n "$1" ]; then
commit="$(date '+%Y-%m-%d %H:%M:%S') by ${USER}"
else
commit="$1 by ${USER}"
fi
echo $commit
git add .
git commit -m "$commit"
# git push -u origin main
git push
}
function m() {
echo "1. 强制更新"
echo "2. 普通更新"
echo "3. 提交项目"
echo "请输入编号:"
read index
case "$index" in
[1]) (forcepull);;
[2]) (pull);;
[3]) (gitpush);;
*) echo "exit" ;;
esac
}
function bootstrap() {
case $1 in
pull) (pull) ;;
m) (m) ;;
-f) (forcepull) ;;
*) ( gitpush $1) ;;
esac
}
bootstrap m