Created
May 14, 2019 21:03
-
-
Save ahota/7ff54ff691326dcf9eb2f414c2b412b0 to your computer and use it in GitHub Desktop.
Git script for updating a fork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USAGE="repository" | |
LONG_USAGE="git update-fork -h | |
print this help message. | |
git update-fork repository | |
Update current branch (assumed to be a fork's master branch) from the | |
provided upstream repository's master branch" | |
SUBDIRECTORY_OK=1 | |
. "$(git --exec-path)/git-sh-setup" | |
function _update_fork() | |
{ | |
if [[ $# == 1 ]]; then | |
git fetch $1 | |
if [[ $? != 0 ]]; then | |
die "Could not fetch from repository $1" | |
fi | |
git pull $1 HEAD:master | |
if [[ $? != 0 ]]; then | |
die "Could not pull from $1/master" | |
fi | |
else | |
usage | |
fi | |
} | |
_update_fork $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment