Skip to content

Instantly share code, notes, and snippets.

@leafo
Created June 6, 2014 00:36
Show Gist options
  • Save leafo/17028b742ed32a3fa384 to your computer and use it in GitHub Desktop.
Save leafo/17028b742ed32a3fa384 to your computer and use it in GitHub Desktop.
function _annotate() {
echo "$(tput setaf 4)>>$(tput sgr0) $@"
eval $@
}
function gup() {
branch=$([[ -n "$1" ]] && echo "$1" || git rev-parse --abbrev-ref HEAD)
dirty=$(git diff --shortstat 2> /dev/null | tail -n1)
_annotate git fetch || return
[[ -n "$dirty" ]] && (_annotate git stash || return)
_annotate git rebase "origin/$branch" || return
[[ -n "$dirty" ]] && (_annotate git stash pop || return)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment