How to Keep Your GitHub Fork in Sync

I’m a full-stack developer who loves learning and building various websites and tools, especially related to real-time data. I’ve been teaching myself to code for the past 10 years while homeschooled my entire life. I'm highly motivated to learn new skills while bringing my all to everything I do.
When you fork a project on GitHub, changes to the original repository do not automatically sync with yours. This can lead to merge conflicts, or when you create a new branch for a PR not having the latest version. Updating your fork can be done with just a few commands.
Initial Setup
If you haven't already done so you will need to set the upstream url for your local environment.
Note: replace
original-authorwith the username that you forked from, andrepo-namewith the repository name.
git remote add upstream https://github.com/original-author/repo-name
Updating Your Fork
Whenever you wish to update your fork, follow the steps below.
Note: replace
masterwith the default branch name if required.
Switch to the main branch
git checkout masterFetch changes from the original repo.
git fetch upstreamMerge changes into local environment.
git merge --ff-only upstream/masterPush changes into fork.
git push origin master
Updating Your Branch
If you started working in a new branch and then changes have come in that you would like to merge, follow the steps below.
Note: replace
my-featurewith your branch name, andmasterwith the default branch name if required.
Switch to your branch.
git checkout my-featureRebase on to the main branch.
git rebase masterResolve any conflicts if needed.
Push your updated branch.
git push --force origin my-feature
