Skip to content

Instantly share code, notes, and snippets.

@rafaelverger
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rafaelverger/20ae5eb8c53e7472318b to your computer and use it in GitHub Desktop.
Save rafaelverger/20ae5eb8c53e7472318b to your computer and use it in GitHub Desktop.
Update all git projects from workspace
#!/bin/bash
PWD=$(pwd)
GIT_ROOT="~/git-projects"
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
_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
cd - > /dev/null
done
echo -e "${GREEN}Done :)${NC}"
cd $PWD > /dev/null
@caio-nas
Copy link

Congrats! Works perfectly!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment