Force syncing a fork

If you have an outdated fork, you first need to sync it with the upstream repository before you can open up a new pull request. A foolproof but annoying solution to get an up-to-date fork is to delete your fork, and then re-fork it. Another approach is to properly sync your fork. However, the few times I've tried to do it the proper way, I usually ran into trouble, and ended up deleting my fork anyway.

An easier way to sync a fork, instead of learning how to do it the proper way, is to force it:

# If you haven't added the upstream repository yet
git remote add upstream [upstream URL]

git fetch upstream

git reset --hard upstream/master

git push --force

This syncs up your fork with the upstream repository. After force syncing, you can create a new branch which can be merged upstream without any merge conflicts.

Keep in mind that by hard resetting you will lose all your changes! Only use this approach if you have no changes that you want to keep.

A picture of me
Hi, I'm Sjors 👋

I write about Laravel and web development. You can follow me on twitter if you want to stay up-to-date on the things I'm doing.

If you want to get in touch, you can email me at