Skip to content

Instantly share code, notes, and snippets.

@lachie
Created May 22, 2012 23:41
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 lachie/2772382 to your computer and use it in GitHub Desktop.
Save lachie/2772382 to your computer and use it in GitHub Desktop.
# gup and friends
function git_current_branch() {
git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///'
}
alias grb='git rebase -p'
alias gup_base='git fetch origin && grb origin/$(git_current_branch)'
function gup() {
if ! git diff-index --quiet HEAD; then
echo your index is dirty
echo please git stash or commit, then rerun gup
else
gup_base
fi
}
# git reset hard - gup
function guph() {
if ! git diff-index --quiet HEAD; then
echo your index is dirty
echo pressing enter blows your changes away
echo ctrl-c to back out
read
fi
git reset --hard HEAD
gup_base
}
# stash - gup - stash pop
function gups() {
local stashed
stashed=$(git stash)
gup_base
if [[ $stashed != "No local changes to save" ]]
then
git stash pop
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment