-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-pullmaster
More file actions
executable file
·37 lines (28 loc) · 872 Bytes
/
git-pullmaster
File metadata and controls
executable file
·37 lines (28 loc) · 872 Bytes
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
#!/bin/bash
###############################################################################
# Handle options
###############################################################################
# Display the help
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
echo -e "
Update master branch and go back to the current branch.
\e[33mUsage:\e[0m
git pullmaster
\e[33mOptions:\e[0m
\e[32m -h, --help \e[0m Display this help message
"
exit 0;
fi
###############################################################################
# Script
###############################################################################
current_branch=$(git currentbranch)
if [ "${current_branch}" = "master" ]; then
git pull && \
git remote prune origin
exit 0
fi
git checkout master && \
git pull && \
git remote prune origin && \
git checkout "${current_branch}"