-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitcommand.sh
More file actions
executable file
·89 lines (74 loc) · 1.85 KB
/
gitcommand.sh
File metadata and controls
executable file
·89 lines (74 loc) · 1.85 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# Local variables
BRANCH=$(git symbolic-ref --short HEAD)
action_push() {
# Push current base data.
# Date=$(date)
printf "%s\n"
echo "Enter the commit message (use Ctrl + d to save): "
CommitM=$(</dev/stdin)
printf "\n"
git init
git add .
git commit -m "$CommitM"
git branch -M "$BRANCH"
git push -u origin "$BRANCH"
}
action_pull() {
git pull
}
action_soft() {
# Remove Last Commit From Current Branch
printf "%s\n"
printf "%s\n" "Are you sure you want to remove your last commit from local and GitHub ?"
printf "%s\n" "Enter yes or no (use Ctrl + d to save): "
Soft=$(</dev/stdin)
if [ "$Soft" == "yes" ]
then
printf "%s\n" "Start reset soft."
git reset --soft HEAD~1
printf "%s\n" "Start pushing data."
git push -f
fi
}
action_diff() {
# Displays the uncommitted changes to the repository.
git diff
}
action_reopen() {
./gitcommand.sh
}
action_help(){
printf "\n%s\n" "status: helping"
printf "\n%s" "Exit, Enter 0. "
printf "\n%s" "Push, Enter 1. "
printf "\n%s" "Pull, Enter 2. "
printf "\n%s" "Remove Last Commit From Current Branch, Enter 3. "
printf "\n%s" "Check Modified Differences, Enter 4. "
printf "\n%s\n" "Reopen gitcommand.sh, Enter 9. "
printf "\n"
}
hello_world() {
while :
do
read -p "Enter the command: " -r Command
case $Command in
0) see_you;;
1) action_push;;
2) action_pull;;
3) action_soft;;
4) action_diff;;
help) action_help;;
9) action_reopen;;
*) printf "\n%s\n" "Command Error";;
esac
printf "\n%s"
done
}
see_you() {
# Stop this program.
printf "\n\n%s\n" "Till next time."
printf "\n"
exit 1
}
hello_world