在公共回购协议中回滚到旧的Git提交 [英] Rollback to an old Git commit in a public repo

查看:89
本文介绍了在公共回购协议中回滚到旧的Git提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何才能回滚到git中的特定提交?



有人可以给我的最佳答案是使用 git revert X次,直到达到所需的提交。

所以,假设我想恢复到20提交的提交,我必须运行20次。

有没有更简单的方法来做到这一点?



我无法使用重置功能,因为此存储库是公开的。

试试这个:

  git checkout [revision]。 

其中 [revision] 是提交哈希(例如: 12345678901234567890123456789012345678ab )。

最后,不要忘记,这非常重要。这将对整个树进行更改。然后提交,你应该很好。



您可以通过

  git reset --hard; 

将删除工作目录和暂存区域中的所有修改。


How can I go about rolling back to a specific commit in git?

The best answer someone could give me was to use git revert X times until I reach the desired commit.

So let's say I want to revert back to a commit that's 20 commits old, I'd have to run it 20 times.

Is there an easier way to do this?

I can't use reset because this repository is public.

解决方案

Try this:

git checkout [revision] .

where [revision] is the commit hash (for example: 12345678901234567890123456789012345678ab).

Don't forget the . at the end, very important. This will apply changes to the whole tree. Then commit and you should be good.

You can undo this by

git reset --hard; 

that will delete all modifications from the working directory and staging area.

这篇关于在公共回购协议中回滚到旧的Git提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆