Dev Notes

Software Development Resources by David Egan.

Sync Forked Repo With Upstream

David Egan

Once you’ve forked and cloned a repo the following describes how to sync the local fork with the upstream remote.

Configure Remote

Check current remotes:

git remote

This will probably output origin, denoting that your repo has a single remote.

Configure a Git remote for the upstream (original) repo:

git remote add upstream


git remote

# Output:

Sync Local Fork with Upstream

There are now three repositories:

  • local
  • origin (GitHub, Bitbucket etc)
  • upstream (The original repo)

Sync from upstream to local, then push changes to origin:

# fetch changes
git fetch upstream

# switch to master branch
git checkout master

# Merge changes from upstream into master
git merge upstream/master

# Push local changes to origin
git push

comments powered by Disqus