Skip to content

Instantly share code, notes, and snippets.

@lathspell
Last active January 5, 2020 17:11
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 lathspell/0fe31e864890d4fd89fc12084101bc24 to your computer and use it in GitHub Desktop.
Save lathspell/0fe31e864890d4fd89fc12084101bc24 to your computer and use it in GitHub Desktop.
Howto keep Git repo with pull requests in sync with upstream

Rebasing

Init Upstream

# Add secondary remote "upstream" for original repository
git remote add upstream https://github.com/exercism/kotlin

Following Upstream

# Reset position to master branch and fetch all changes from upstream/master
git checkout master
git fetch --all
# Incorporate upstream/master to local master and push it to our repository
git rebase upstream/master
git push

Custom Branch

git checkout -b foo
# only once
git push --set-upstream origin armstrong-numbers
# afterwards
git push
# Make pull-request via Browser
# Delete branch origin/foo via Browser
# Delete the origin/foo branch in the local repositoriy, too
git fetch --prune
# Delete the local branch, too
git branch -D foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment