git - 删除HEAD前的提交 [英] git - Remove commit before HEAD

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

问题描述

好的,我是Git的新手,想知道如何在HEAD之前删除提交。例如 - :

  commit foo(这是HEAD)

commit bar(这是什么我想删除)

如何删除提交栏完全从这个分支,但保持提交foo

解决方案

git rebase -i HEAD〜2



会让你互动地移除提交

git rebase将删除该提交的所有引用并更改HEAD提交的标识。意思是人们可能会遇到问题,如果他们从旧的提交中分支出来的话



git revert< commitID>



可能是保留历史记录的更好方法

Okay I am new to Git and would like to know how to remove a commit before the HEAD. For instance-:

commit foo (This is the HEAD)

commit bar (This is what I want to remove)

How do I delete commit bar entirely from this branch but keep commit foo?

解决方案

git rebase -i HEAD~2

Will let you interactivly remove the commit

git rebase will remove all reference of that commit and change the id of the HEAD commit. Meaning people MAY have issues if they have branched from the old commit

git revert <commitID>

may be a better way to keep history

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

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