Skip to content

Instantly share code, notes, and snippets.

@jhersh
Last active August 29, 2015 14:06
Show Gist options
  • Save jhersh/b274bb71d4eb73e4b4bf to your computer and use it in GitHub Desktop.
Save jhersh/b274bb71d4eb73e4b4bf to your computer and use it in GitHub Desktop.
Git get & put
# Current branch name
alias gbr='git symbolic-ref --short HEAD'
alias gs='git status -sb'
# Fetch and rebase on top of the current branch from origin.
# Optionally specify a single argument as the name of the branch to rebase upon.
#
# Suppose you're on master.
# `gget` will fetch origin's master and rebase your current commits on top of origin.
#
# Suppose you're on branch featureA.
# `gget master` will fetch origin's master and rebase featureA's commits on top of master.
function gget()
{
BRANCH=`gbr`
if [ -z "$1" ]; then
TARGET="$BRANCH"
else
TARGET="$1"
fi
gs && git fetch -pt --progress origin && git pull --rebase origin "$TARGET"
}
function gput()
{
BRANCH=`gbr`
EXTRA="$1" || ""
gs && git push origin "$BRANCH" $EXTRA
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment