Add gsync function for upstream Git branch syncer.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user