Skip to content

Instantly share code, notes, and snippets.

@leafo
Last active December 27, 2015 19:58
Show Gist options
  • Save leafo/7380556 to your computer and use it in GitHub Desktop.
Save leafo/7380556 to your computer and use it in GitHub Desktop.
gup
function _annotate() {
echo "$(tput setaf 4)>>$(tput sgr0) $@"
$@
}
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