- You need the rights to reopen pull requests on the repository.
- The pull request hasn't been merged, just closed.
- Write down the current commit hash of your PR-branch
git log --oneline -1 <PR-BRANCH>
- Write down the latest commit hash on github before the PR has been closed.
git push -f origin <GITHUB-HASH-FROM-STEP-2>:<PR-BRANCH>
- Reopen the PR.
git push -f origin <HASH-FROM-STEP-1>:<PR-BRANCH>
You've a PR branch my-feature
currently at 1234567
. Looking at the the PRs page, we see that the PR was closed when my-feature
pointed at 0abcdef
.
git push -f origin 0abcdef:my-feature
#pushing the old commit the PR has been closed with
- Reopen the PR.
git push -f origin 1234567:my-feature
#pushing the latest commit
When you do a soft reset in order to squash commits, then forget to commit and force push the branch, it closes the PR with this error. Thank you for this, as with everyone else here, I'll chime in that this saved the day.