繁体   English   中英

如何将公共Git回购恢复为特定的先前提交?

[英]How to Revert Public Git Repo to Specific Previous Commit?

我想恢复一个公共回购,我最近克隆回一年前的自己的先前版本。 我不想做一个很难恢复。

我已经尝试过了:

cd MyRepo
git revert --no-commit dc3b4359.. 

但我得到了这个错误:

error: could not revert dc3b4359...
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'

我是新手; 什么代码可以用来安全地做到这一点? 提前致谢。

(已编辑) (谢谢@torek)

最粗糙的方式是:

cd MyRepo
git rm -r .
git checkout dc3b4359 -- .
git add .
git commit -m "Going back in time"
git push origin master

原始答案:

cd MyRepo
rm -rf * # if you have files starting with '.', delete them too.
git checkout dc3b4359 -- .
git add .
git commit -m "Going back in time"

暂无
暂无

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

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