Add gsync function for upstream Git branch syncer.

This commit is contained in:
Jeff Geerling
2017-01-20 09:46:26 -06:00
parent daee144bac
commit 8f75b764ca
+19
View File
@@ -58,6 +58,25 @@ alias gl='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %
alias gsd='git svn dcommit' alias gsd='git svn dcommit'
alias gsfr='git svn fetch && git svn rebase' 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. # Turn on Git autocomplete.
brew_prefix=`brew --prefix` brew_prefix=`brew --prefix`
if [ -f $brew_prefix/etc/bash_completion ]; then if [ -f $brew_prefix/etc/bash_completion ]; then