askielboe's answer worked well for me, when I was in a similar situation (2024-11-15), with two modifications:
curl https://github.com/USER/REPOSITORY/pull/1.patch | git am
did not work for me. So I visited https://github.com/USER/REPOSITORY/pull/1.patch and found I was redirected to https://patch-diff.githubusercontent.com/raw/USER/REPOSITORY/pull/1.patch, for whatever reason. curl https://patch-diff.githubusercontent.com/raw/USER/REPOSITORY/pull/1.patch | git am
did work for me. Who knows why, ha ha.As the other answers and comments have said, you can also probably git fetch origin pull/ID/head:BRANCH_NAME
à la https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally, if that's more useful to you somehow.