Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created November 8, 2010 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tebeka/668017 to your computer and use it in GitHub Desktop.
Save tebeka/668017 to your computer and use it in GitHub Desktop.
_gitsync() {
if [ $# -eq 1 ]; then
repo=origin
else
repo=$2
fi
branch=$(git branch --no-color | grep '^*' | awk '{print $2}')
if [ -z "$branch" ]; then
# git will show an appropriate error
return 1
fi
if [ $repo != origin ] && [ $branch != master ]; then
echo "error: refusing to $1 to branch $branch on $repo"
return
fi
echo git $1 --tags $repo $branch
git $1 --tags $repo $branch
}
push() {
_gitsync push $1
}
pull() {
_gitsync pull $1
}
complete -W "origin upstream" pull
complete -W "origin upstream" push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment