Recover a commit sent as a pull-request from a deleted fork on GitHub
It is possible to fetch
pull requests to your local machine.
Without having a link to the pull request in question it's hard to test whether this will work, but you can try to
- create a new fork of the repository,
- clone your new fork,
-
fetch
your pull request from the upstream repository,git remote add upstream https://github.com/User/repository.git $EDITOR .git/config # Add `fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*` to # the relevant section, as outlined in the linked page. Note that # we use `upstream` instead of `origin` as the target. git fetch upstream
-
merge
the pull request into your local repository, e.g.git checkout master git merge --ff-only upstream/pr/1
and then
push
it back to your new fork.
If that fails, you can submit a support request to GitHub asking them to restore your repository. From an FAQ about security:
We do not retroactively remove repositories from backups when deleted by the user, as we may need to restore the repository for the user if it was removed accidentally.
To initiate this process, contact their support team as soon as possible.