Last active
May 11, 2017 11:32
-
-
Save mmellado/9047826082718245c562355f34f921d4 to your computer and use it in GitHub Desktop.
Sync your forks
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
function gsync { | |
# Before using this script, make sure to add upstream to your local repository | |
# git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git | |
BRANCH="master" | |
if [ $# -eq 1 ] | |
then | |
BRANCH="$1" | |
fi | |
# Fetch the latest state of the repository | |
git fetch --all --tags --prune | |
# Get the lastest from upstream | |
echo "Patching with upstream/$BRANCH" | |
git rebase upstream/$BRANCH | |
# force push with the latest | |
echo "Updating origin/$BRANCH with upstream/$BRANCH" | |
git push --force origin $BRANCH | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
~/.bashrc
(or your shell profile of preference)source ~/.bashrc
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
gsync
to sync to upstream/mastergsync [branch]
to sync to upstream/branch