-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitScript.sh
70 lines (60 loc) · 1.52 KB
/
GitScript.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
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
Op=$1
Arg=$2
# Up - git commit -a -m $Arg & git push
# Down - git pull & git checkout main
# Log - git log --oneline
# Cred - git config --global --unset credential.helper & git config --global credential.helper store
#echo Op: !Op!
#echo Arg: !Arg!
case $Op in
Up)
if [[ -z $Arg ]]; then
echo "Usage: GitScript Up <Commit Messages>"
exit
fi
echo "Will execute: git commit -a -m $Arg, git push"
read -p "Please confirm [Y/n]: " -n 1 -r
if [[ $REPLY =~ ^[Nn]$ ]]; then
exit
fi
echo "Commiting..."
git add --all
git commit -a -m $Arg
echo "Pushing..."
git push
;;
Down)
echo "Will execute: git pull, git checkout main"
read -p "Please confirm [Y/n]: " -n 1 -r
if [[ $REPLY =~ ^[Nn]$ ]]; then
exit
fi
echo "Pulling..."
git pull
echo "Checking out..."
git checkout main
;;
Log)
git log --oneline
;;
Cred)
echo "Will execute: git config --global --unset credential.helper, git --global config credential.helper store"
read -p "Please confirm [Y/n]: " -n 1 -r
if [[ $REPLY =~ ^[Nn]$ ]]; then
exit
fi
git config --global --unset credential.helper
git config --global credential.helper store
;;
*)
echo "Usage: GitScript ^<Option^> [Optional Argument]"
echo "Available options:"
echo " Up Commit and push to remote, require optional argument: commit message"
echo " Down Pull and checkout main branch"
echo " Log Check git one-line log"
echo " Cred Remove and update credential in next operation"
exit
;;
esac
echo "Command completed."