Skip to content

Instantly share code, notes, and snippets.

@helielson
Forked from rafaelverger/git-global-pull.sh
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helielson/a993fda5db899425b259 to your computer and use it in GitHub Desktop.
Save helielson/a993fda5db899425b259 to your computer and use it in GitHub Desktop.
#!/bin/bash
PWD=$(pwd)
GIT_ROOT=~/workspace
CYAN='\033[36m'
GREEN='\033[32m'
NC='\033[0m' # No Color
cd $GIT_ROOT > /dev/null
PROJECTS="$@"
if [[ $# -eq 0 ]] || [[ "$1" == "all" ]]; then
PROJECTS="*/"
fi
for project in $PROJECTS
do
if [[ ! -d "$project" ]]; then
project="jusbrasil-$project"
fi
echo -e "${CYAN}Updating $project${NC}"
cd $project > /dev/null
if [ -d ".git" ]; then
_changes=$(git status | grep Changes)
[ -z "$_changes" ] || git stash
echo "git pull and updating submodules..."
git pull --rebase && git submodule update --init
echo "removing branches deleted remotely"
git fetch -p
[ -z "$_changes" ] || git stash pop
else
echo "$project is not a git project"
fi
cd - > /dev/null
done
echo -e "${GREEN}Done :)${NC}"
cd $PWD > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment