Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # define colors
- CYAN='\033[0;36m'
- GREEN='\033[0;32m'
- RED='\033[0;31m'
- # no color
- NC='\033[0m'
- # check if this directory is a git repository
- if [ ! -d .git ]; then
- printf "${RED}ERROR: this directory is not a git repository${NC}\n";
- exit 1
- fi
- #check if git is installed
- if ! command -v git &> /dev/null; then
- printf "${RED}ERROR: git command not found${NC}\n";
- exit 1
- fi
- # get git command path
- gitCommand=$(which git)
- # get current branch
- current=$(${gitCommand} branch | grep \* | sed 's/\* //g')
- # loop over all local branches and pull them
- ${gitCommand} branch |sed 's/\* //g' |while read -r branch; do
- printf "\n${CYAN}PULL ${branch}${NC}\n";
- ${gitCommand} checkout "${branch}"
- ${gitCommand} pull
- done
- # return to initial branch
- printf "\n${GREEN}RETURN TO ${current}${NC}\n";
- ${gitCommand} checkout "${current}"
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement