Suppose your fork remote is named fork, and your upstream remote is named original. You are working on the branch main.
Make sure that you are on branch main, and that you have no local changes. I.e. running:
git statusshould produce something like:
On branch main
Your branch is up to date with 'fork/main'.
Now, what you want to do is fetch changes from upstream:
git fetch --prune original
git reset --hard original/main
git clean -f -dThis makes your local repo exactly like your remote repo. Then you can update your fork with latest from upstream:
git push --force fork main