删除旧的git提交 [英] Remove old git commits

查看:97
本文介绍了删除旧的git提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

 > git log  - -pretty = oneline --abbrev-commit 
2f05aba添加了新功能
3371cec固定螺丝< - 我想移除这个
daed25c拧紧& - 并移除它。
e2b2a84首先。所以这就像他们从未发生过。

这可能吗?

解决方案

这可以通过 git rebase 来实现。尝试以下操作:

  git rebase -i HEAD〜4 

,然后按照编辑器中的交互式说明进行操作。在第一步中,压扁提交。它应该看起来像这样:

 选择2f05aba ...将被保留
壁球3371cec ...将用daed25c
压扁daed25c ...将被压扁,用e2b2a84
挑出e2b2a84 ..将包含这个和3371cec和daed25c

在第二步中,您可以编辑提交消息。


I'm very new to git, and was wondering if something like this is possible?

>git log --pretty=oneline --abbrev-commit
2f05aba Added new feature
3371cec Fixed screw up    <-- I want to remove this
daed25c Screw up          <-- and remove this.
e2b2a84 First.                So it's like they never happend.

Is this possible?

解决方案

This is possible with git rebase. Try the following

git rebase -i HEAD~4

and then, follow the interactive instructions in your editor. In the first step you "squash" the commits. It should look something like this:

pick 2f05aba ... will be preserved
squash 3371cec ... will be squashed with daed25c
squash daed25c ... will be squashed with e2b2a84
pick e2b2a84 .. will contain this and 3371cec and daed25c

In the second step you can edit the commit messages.

这篇关于删除旧的git提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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