forked from zainabdnaya/ft_transcendence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush.sh
executable file
·36 lines (29 loc) · 1.01 KB
/
push.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
#!/bin/bash
# get current branch and push
#
current_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
case "$branch" in
'('?*')') echo not on any branch ;;
*) echo on branch $branch ;;
esac
#esac statement is to give an expression to evaluate and to execute several different statements based on the value of the expression. The interpreter checks each case against the value of the expression until a match is found.
#If nothing matches, a default condition will be used.
# git pull
git pull origin "$current_branch"
echo "====pull changes from '$current_branch' branch"
# get the argument message
message="$1"
# If no commit message is passed, use current date time in the commit message
if [[ -z "${message// }" ]]
then
message=$(date '+%Y-%m-%d %H:%M:%S')
fi
# stage all changes
git add .
echo "====staged all git files"
# add commit
git commit -m "$message"
echo "====added the commit with message: '$message'"
# git push
git push origin "$current_branch"
echo "====pushed changes to '$current_branch' branch"