Skip to content

Instantly share code, notes, and snippets.

@selfup
Last active February 6, 2019 00:48
Show Gist options
  • Save selfup/babc75e0aa1b24d3bfac198066c960ed to your computer and use it in GitHub Desktop.
Save selfup/babc75e0aa1b24d3bfac198066c960ed to your computer and use it in GitHub Desktop.
# git sync upstream
function gsu() {
set -e
UPSTREAM_CHECK=$(git remote -v | grep upstream || echo '')
if [[ $UPSTREAM_CHECK == '' ]]
then
echo "NO UPSTREAM SET -- ABORTING"
exit 1
fi
MASTER_CHECK=$(git status | grep 'On branch master' || echo '')
if [[ $MASTER_CHECK == '' ]]
then
echo "NOT ON MASTER -- ABORTING"
exit 1
fi
CLEAN_CHECK=$(git status | grep 'nothing to commit, working tree clean' || echo '')
if [[ $CLEAN_CHECK == '' ]]
then
echo "BRANCH IS NOT CLEAN -- ABORTING"
exit 1
fi
git fetch upstream
git rebase upstream/master
git push origin master
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment