Skip to content

Instantly share code, notes, and snippets.

@jefffis
Created February 25, 2015 21:24
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 jefffis/a5536a7e4693eafbb9da to your computer and use it in GitHub Desktop.
Save jefffis/a5536a7e4693eafbb9da to your computer and use it in GitHub Desktop.
Forked from https://gist.github.com/ryangreenberg/869658 to make it work with pulling from current branch
#!/bin/sh
# Shortcut for git pull origin [current_branch]
# Mnemonic: plb for "pull branch"
if git rev-parse --git-dir > /dev/null 2>&1 # Current directory is a git repository
then
# http://stackoverflow.com/questions/1593051/
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD
branch_name=${branch_name##refs/heads/}
echo "git pull origin $branch_name"
git pull origin $branch_name "$@"
else
echo "Error: The current directory does not appear to be a git repository"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment