Created
April 29, 2017 19:32
-
-
Save donovank/2ba32d30c7430a0045b931060a3acaf9 to your computer and use it in GitHub Desktop.
Forksync, a bash function to sync forked repos easily.
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
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