Skip to content

Instantly share code, notes, and snippets.

@donovank
Created April 29, 2017 19:32
Show Gist options
  • Save donovank/2ba32d30c7430a0045b931060a3acaf9 to your computer and use it in GitHub Desktop.
Save donovank/2ba32d30c7430a0045b931060a3acaf9 to your computer and use it in GitHub Desktop.
Forksync, a bash function to sync forked repos easily.
forksync() {
if [ ! -d ".git" ]; then
echo "Make sure your in the root of a github repo."
return
fi
if cat .git/config | grep -q 'remote "upstream"' .git/config; then
git add .
git stash
git fetch upstream
git rebase upstream/master
git stash pop
git add .
git commit -m "forksync"
git push
else
echo "please run the following:"
echo "git remote add upstream git@github.com:username/repo.git"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment