Skip to content

Instantly share code, notes, and snippets.

@CristinaSolana
Created February 22, 2012 14:56
Show Gist options
  • Save CristinaSolana/1885435 to your computer and use it in GitHub Desktop.
Save CristinaSolana/1885435 to your computer and use it in GitHub Desktop.
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream

3. Updating your fork from original repo to keep up with their changes:

git pull upstream master
@sami2020pro
Copy link

Thank you ❤️

@vivian-duong
Copy link

git pull is a git fetch and git merge in one step.
So the git fetch in step 2 is redundant if you're going to do a git pull anyway.

I second this. git fetch and then git pull won't break anything, but it's redundant.

@maryamrmz
Copy link

You can update it to:

git pull upstream main

@rebase-upstream
Copy link

This post should have been the first Google result. Would have saved me some time.

@emrecoban
Copy link

You can update it to:

git pull upstream main

thank you @maryamrmz it worked for me!

@mwaeckerlin
Copy link

How to keep a full project in sync, all the branches from the server and automated (no local checkout)?

I just want a slave mirror.

@mathieucarbou
Copy link

mathieucarbou commented Apr 29, 2021

Found an automatic and flexible solution using Github Actions that can be easily applied quickly to any fork.
See my blog post: https://blog.mathieu.photography/post/649318432483033088/automatic-fork-syncing-with-github
Or Gist: https://gist.github.com/mathieucarbou/96ab30024f0d3fb44cac970219d23efc

@liosc
Copy link

liosc commented Mar 19, 2022

Hi everyone.
I tried the commands suggested in this post. I was able to add the remote but when I try to pull for updating local I get the error "The unauthenticated git protocol on port 9418 is no longer supported.". I solved it using http// instead of git// when adding the upstream.

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