Skip to content

Instantly share code, notes, and snippets.

@jeremykohn
Created March 9, 2017 10:33
Show Gist options
  • Save jeremykohn/016fdd880e3988224c3783754b5d5875 to your computer and use it in GitHub Desktop.
Save jeremykohn/016fdd880e3988224c3783754b5d5875 to your computer and use it in GitHub Desktop.
Sync master branch of forked repo with upstream master branch
# Part 1, if necessary:
# Configure a remote for your fork
# https://help.github.com/articles/configuring-a-remote-for-a-fork/
# In Terminal, cd into your local repo and run this command:
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
# In general, git remote add upstream <upstream repo>
# Verify by running this command:
git remote -v
# Part 2:
# Sync your fork with upstream repo
# https://help.github.com/articles/syncing-a-fork/
git fetch upstream
git checkout master
git merge upstream/master
# Part 3:
# Push changes from your local repo to remote
# https://help.github.com/articles/pushing-to-a-remote/
git push origin master
# In general, git push <REMOTENAME> <BRANCHNAME>
# Here, 'origin' is your fork's repo on GitHub.
# Done. The master branch of your forked repo,
# both locally and remotely,
# is now even with the upstream master branch.
@jeremykohn
Copy link
Author

Also see https://gist.github.com/xaxim/0ad48b3afe6e81fa6097d82b22ed8cde

git fetch upstream
git checkout master
git merge upstream/master
git merge upstream/master
git commit
git push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment