DEV Community


Sync a GitHub forked repository

tawfikyasser profile image Tawfik Yasser ・1 min read

After forking a repository on GitHub, You need to make some changes as a contributions, So you starting with make updates, Then commit it, And finally push them and send a Pull Request, But the problem that the repository maintainer comment on your PR and tell you that your changes are a head.

Alt Text

So what is the problem?

Usually the problem that your copy of the repository is older than the original repository, In another words, Some changes made to the repository after you forked it and you don’t synced it yet.

So all what you need to do is to sync it, and we will use CLI to make this.


Change the directory to your local repository:

cd <repo-name>


Add the remote to your repo. and call it upstream:

git remote add upstream <original-repo-link>


Fetch all the remote branches:

git fetch upstream


Merge your master or main with changes:

git merge upstream/master or main


Now you can push the updated changes to your remote forked repo:

git push

Make sure that you are on the master or main branch

I hope this be useful folks :)

Have a nice time.

Discussion (0)

Forem Open with the Forem app