简体   繁体   English

如何恢复存储库以提交

[英]How to revert repository to commit

I pushed a commit to the repo, and now the master repo is messed up and I want to revert master to commit a) which happened a while ago.我向 repo 提交了一个提交,现在主 repo 搞砸了,我想恢复 master 以提交 a) 之前发生的事情。

I can't modify the master repo directly so I have to create a pr to modify it.我不能直接修改主仓库,所以我必须创建一个 pr 来修改它。 How can I revert master to the old commit a)?如何将 master 恢复为旧的提交 a)?

I've tried我试过了

git checkout -b revertbranch
git reset HEAD --hard a
git add .
git commit -m "revert"
git push

However, when I try to open a pull request, I get a message on github that says no files are changed.但是,当我尝试打开拉取请求时,我在 github 上收到一条消息,指出没有文件被更改。

Can someone help?有人可以帮忙吗?

Answer:回答:

git checkout branch_x
git reset --soft master
git commit -m "commit message"
git push -f "message"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM