Skip to content

Instantly share code, notes, and snippets.

@jeremytregunna
Created October 23, 2014 15:29
Show Gist options
  • Save jeremytregunna/d1660f5239600b342d22 to your computer and use it in GitHub Desktop.
Save jeremytregunna/d1660f5239600b342d22 to your computer and use it in GitHub Desktop.
#!/bin/zsh
if [ X"$1" = X"-h" ]; then
echo "Usage: git grab [remote]"
echo " Fetches changes from the supplied remote, or origin if omitted and rebases changes"
echo " onto your branch."
exit 0
fi
REMOTE=$1
[ -z ${REMOTE} ] && REMOTE="origin"
function git_current_branch() {
git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///'
}
git fetch ${REMOTE} && git rebase -p ${REMOTE}/$(git_current_branch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment