Joking aside, "git pull -r" is pure magic in the face of upstream rewrites. It always does the right thing:
https://mergebase.com/doing-git-wrong/2018/03/07/fun-with-gi...
After I wrote that blog post someone told me the reason for the magic is the use of "git merge-base --fork-point" under the hood.