我做了一件蠢事......
- 我在 GitHub 上fork了一个 repo。
- 我做了一些更改,提交到我的分支上。
- 我将此提交作为 pull 请求发送回原始存储库。
- 愚蠢的部分来了:我删除我的 fork 。
原始存储库的所有者在接受 pull 请求之前要求对我的代码进行一些更改,我很乐意这样做。
我尝试重新 fork repo 协议(protocol),但我无法从 pull 请求中 check out 提交,它甚至不存在 “未链接”提交(不属于任何分支或标记的提交,我不知道官方术语)。
我的问题是:如何恢复作为 pull 请求发送的提交?
如果没有办法,可以选择在新提交中重新进行更改,但 pull 请求会丢失。 我的问题不是不丢失提交的更改,而是不丢失 git 历史,这意味着保留提交的 SHA1(以及我可能不知道的任何其他内容) ).
最佳答案
有可能fetch
pull requests to your local machine .
如果没有指向相关 pull 请求的链接,很难测试这是否有效,但您可以尝试
- 创建一个新的存储库分支,
- 克隆你的新分支,
从上游存储库获取
您的 pull 请求,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
将 pull 请求 merge
到您的本地存储库中,例如git checkout master git merge --ff-only upstream/pr/1
然后将其
推送
到您的新分支。
如果失败,您可以向 GitHub 提交支持请求,要求他们恢复您的存储库。来自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.
要启动此过程,contact their support team尽快。
关于git - 从 GitHub 上已删除的复刻中恢复作为 pull 请求发送的提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20977530/