Created
November 28, 2016 15:44
-
-
Save tuxcanfly/8e3a6fcf902d4af83d06b3587dcf1993 to your computer and use it in GitHub Desktop.
gitup - update multiple repos while taking care of dirty indexes in different branches
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 | |
for dir | |
do | |
pushd $dir | |
STASHED=false | |
BRANCH=false | |
if [[ -n $(git status --porcelain) ]] | |
then | |
git stash | |
STASHED=true | |
fi | |
branch=$(git branch | grep "*" | cut -d ' ' -f 2) | |
if [ $branch != master ] | |
then | |
git checkout master > /dev/null 2>&1 | |
BRANCH=true | |
fi | |
git pull --ff-only > /dev/null | |
if $BRANCH | |
then | |
git checkout - > /dev/null 2>&1 | |
fi | |
if $STASHED | |
then | |
git stash pop | |
fi | |
git status -s | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment