Skip to content

Instantly share code, notes, and snippets.

@bazay
Created May 28, 2019 15:18
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 bazay/1da22ea75116cde6ae9da0e3e1a5ded2 to your computer and use it in GitHub Desktop.
Save bazay/1da22ea75116cde6ae9da0e3e1a5ded2 to your computer and use it in GitHub Desktop.
A helpful bash script that allows you to simply
#!/bin/bash
#
# gup BRANCH
#
# Update origin with upstream for a specified branch. This allows you to update a branch on your forked repo
# with the most up-to-date version on the parent, all via the CLI.
#
# Note* This function assumes the following remotes:
# 1. `origin` - Refers to your forked repository, required;
# 2. `upstream` - The parent of your forked repository.
function gup () {
if [[ -z "$1" ]]; then
echo "ERROR: Please specify a branch name! E.g."
echo " gup BRANCH"
return 1
fi
git fetch upstream && git co $1 && git pull upstream $1 && git push origin $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment