-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitPushSetUpstream
executable file
·40 lines (33 loc) · 1.04 KB
/
gitPushSetUpstream
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
#!/bin/bash
###########################################
# Pushes the local branch you have up #
# to origin/develop, confirmation #
# required #
###########################################
source ~/bash-helpers/_colours
branchName=$(git branch | grep \* | cut -d ' ' -f2)
if [ "$branchName" == "main" ]; then
echo "${RED}You are on the main branch. You should not use this command on main."
exit 1
fi
if [ "$branchName" == "develop" ]; then
echo "${RED}You are on the develop branch. You should not use this command on develop."
exit 1
fi
echo "You are on the branch: ${LMAGENTA}${branchName}${RESTORE}"
while true; do
read -p "Is this the correct branch? Pressing yes will run the following command:
${BLUE}git push --set-upstream origin $branchName${RESTORE}
(y/n) " yn
case $yn in
[Yy]*)
git push --set-upstream origin "$branchName"
break
;;
[Nn])
echo 'Exiting...'
exit 1
;;
*) echo "Please answer yes or no." ;;
esac
done