diff --git a/.bash_profile b/.bash_profile index abe661e..d824349 100644 --- a/.bash_profile +++ b/.bash_profile @@ -58,6 +58,25 @@ alias gl='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset % alias gsd='git svn dcommit' alias gsfr='git svn fetch && git svn rebase' +# Git upstream branch syncer. +# Usage: gsync master (checks out master, pull upstream, push origin). +function gsync() { + if [[ ! "$1" ]] ; then + echo "You must supply a branch." + return 0 + fi + + BRANCHES=$(git branch --list $1) + if [ ! "$BRANCHES" ] ; then + echo "Branch $1 does not exist." + return 0 + fi + + git checkout "$1" && \ + git pull upstream "$1" && \ + git push origin "$1" +} + # Turn on Git autocomplete. brew_prefix=`brew --prefix` if [ -f $brew_prefix/etc/bash_completion ]; then