在Git中删除较早的提交 [英] Delete earlier commits in Git
本文介绍了在Git中删除较早的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除几个较早的提交.这就是我的仓库现在的样子-
I want to delete a couple of earlier commits. This is what my repo looks like now -
R----A----B----C----HEAD.
我想删除提交A和C,还放弃它们所做的更改.这就是我的仓库的样子-
I want to remove commits A and C and also discard changes made by them. This is how my repo should look like -
R----B-----HEAD.
如何在Git中做到这一点?
How can I do this in Git?
谢谢.
推荐答案
使用git rebase -i R
,删除A
和C
行并保存.
Use git rebase -i R
, delete the A
and C
lines and save.
请参阅Git社区手册中的交互式重订和
See Interactive Rebasing from Git Community Book and reorder commits with rebase from git ready for details.
这篇关于在Git中删除较早的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文