Last active
August 29, 2015 14:06
-
-
Save rafaelverger/20ae5eb8c53e7472318b to your computer and use it in GitHub Desktop.
Update all git projects from workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Congrats! Works perfectly!!!