Recover commits deleted by force push

Hi, I accidentally force pushed to my repo and caused two commits to become dangling. Thankfully, they are referenced by a GitHub PR and a GitHub issue so they are still viewable via the UI (see here https://github.com/PatrickF1/fzf.fish/compare/main...84a0cd765a211cbfdf539aa7e8d22d0aa0d463b9). I want to fix this but cannot fix it locally because I never fetched the two commits in question. I also tried fixing it from GitHub but the compare UI (see the link I posted above) does not let me create a PR or branch from it. What do I do to bring back these two commits?

I asked GitHub support privately and they helped me resolve it! Here’s their reply

It’s possible to restore your repository’s state if you know the last commit before the force push. You can replace the /commit/ part in the URL with /tree/ to reach the tree view for that commit. Let’s say you know the commit SHA, in this case it’s 84a0cd765a211cbfdf539aa7e8d22d0aa0d463b9.

In your browser, you can navigate to the repository’s state at that commit (the Tree View):

https://github.com/PatrickF1/fzf.fish/tree/84a0cd765a211cbfdf539aa7e8d22d0aa0d463b9

From here, you can create a new branch by clicking the 84a0cd765a button, and typing in a name for it. That would create a branch from your repository’s state at the time of that commit.