Created
November 10, 2010 18:02
-
-
Save maniksurtani/671229 to your computer and use it in GitHub Desktop.
Updates a local clone of your personal fork of an upstream project to the latest code in the upstream repository.
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 | |
# Can be a full repo URL or a short name if you have added it as a remote | |
UPSTREAM="upstream" | |
ORIGIN="origin" | |
LOCAL_CLONE_OF_FORK="$HOME/Code/infinispan/my_repo" | |
BRANCHES_TO_SYNC="master 4.2.x" | |
cd $LOCAL_CLONE_OF_FORK | |
git fetch -q $UPSTREAM | |
git fetch -q $UPSTREAM --tags | |
for B in $BRANCHES_TO_SYNC ; do | |
git checkout -q $B | |
ST=`git status --porcelain` | |
if [ "x$ST" == "x" ] ; then | |
STASH=FALSE | |
else | |
STASH=TRUE | |
git stash | |
fi | |
git pull -q $UPSTREAM $B | |
git push -q $ORIGIN $B | |
if [ $STASH == "TRUE" ] ; then | |
git stash pop | |
fi | |
done | |
git push -q $ORIGIN --tags | |
echo "Local clone and $ORIGIN synced with $UPSTREAM" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment