简体   繁体   English

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

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

I want to revert a public repo I recently cloned back to a previous version of itself from a year ago. 我想恢复一个公共回购,我最近克隆回一年前的自己的先前版本。 I don't want to do a hard revert. 我不想做一个很难恢复。

I have already tried this: 我已经尝试过了:

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

But I got this error: 但我得到了这个错误:

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

I am a novice at this; 我是新手; what code could be used to do this safely? 什么代码可以用来安全地做到这一点? Thanks in advance. 提前致谢。

(EDITED) (thanks @torek) (已编辑) (谢谢@torek)

The most crude way would be: 最粗糙的方式是:

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

Original answer: 原始答案:

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