Skip to content

Instantly share code, notes, and snippets.

@agusbrand
Last active June 13, 2021 21:35
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 agusbrand/198d3d9512b7a3495c7f51a1bf30fda3 to your computer and use it in GitHub Desktop.
Save agusbrand/198d3d9512b7a3495c7f51a1bf30fda3 to your computer and use it in GitHub Desktop.
Keep a fork in sync with upstream in git

Keep a fork in sync with upstream in git

1. Add a new remote to point to the upstream repo:

 > git remote add upstream git://github.com/USERNAME/UPSTREAM-REPO.git

2. Check remotes:

> git remote -v

origin  git@github.com/MY-USERNAME/MY-FORK-REPO.git (fetch)
origin  git@github.com/MY-USERNAME/MY-FORK-REPO.git (push)
upstream        git@github.com/USERNAME/UPSTREAM-REPO.git (fetch)
upstream        git@github.com/USERNAME/UPSTREAM-REPO.git (push)

3. Pull changes from upstream to master:

> git pull upstream master

4. Push changes to origin from master:

> git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment