有什么办法可以删除Mercurial中的本地提交? [英] Is there any way to delete local commits in Mercurial?

查看:77
本文介绍了有什么办法可以删除Mercurial中的本地提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在Mercurial中犯了一个愚蠢的错误.通常,我会在不进行汞拉"和汞更新"的情况下开始工作.当我尝试推送更改时,出现错误.

So I keep making a silly mistake in Mercurial. Often times, I'll start work without doing an "hg pull" and an "hg update." When I try to push my changes, I get an error.

有什么办法可以删除我的本地提交,这样我就可以避免创建多个标头,分支等.我只想删除我的本地提交,将我的更改与提示合并,然后重新提交.听起来很简单,对吧?我似乎找不到任何轻松删除本地提交的方法,因此我可以与提示完全合并.

Is there any way to delete my local commits so I can avoid creating multiple heads, branches, etc? I just want to delete my local commits, merge my changes with the tip, and then re-commit. Sounds simple, right? I can't seem to find any way to easily delete local commits so I can cleanly merge with the tip.

同样,我只想删除使用"hg ci"进行的本地提交.我不想修改文件,还原等.

Again, I'm only trying to delete local commits made with "hg ci". I don't want to modify files, revert, etc.

推荐答案

启用"地带"扩展名并输入以下内容:

Enable the "strip" extension and type the following:

hg strip #changeset# --keep

#changeset#是要删除的变更集的哈希.这将删除所说的变更集,包括从其衍生的变更集,并使您的工作目录保持不变.如果您还希望还原已提交的代码更改,请删除--keep选项.

Where #changeset# is the hash for the changeset you want to remove. This will remove the said changeset including changesets that descend from it and will leave your working directory untouched. If you wish to also revert your committed code changes remove the --keep option.

有关更多信息,请检查 Strip扩展.

For more information, check the Strip Extension.

如果您收到未知命令'strip'",则可能需要启用它.为此,请找到.hgrcMercurial.ini文件并将以下内容添加到其中:

If you get "unkown command 'strip'" you may need to enable it. To do so find the .hgrc or Mercurial.ini file and add the following to it:

[extensions]
strip =


请注意(如Juozas在他的评论中所述),具有多个负责人是Mercurial中的正常工作流程.您不应该使用strip命令来解决这个问题.相反,您应该将自己的头部与传入的头部合并,解决所有冲突,进行测试,然后再进行推送.


Note that (as Juozas mentioned in his comment) having multiple heads is normal workflow in Mercurial. You should not use the strip command to battle that. Instead, you should merge your head with the incoming head, resolve any conflicts, test, and then push.

当您真的想摆脱污染分支的变更集时,strip命令很有用.实际上,如果您处于此问题的情况下,并且您想要完全删除所有草稿"永久更改集,请查看最佳答案,基本上建议这样做:

The strip command is useful when you really want to get rid of changesets that pollute the branch. In fact, if you're in this question's situation and you want to completely remove all "draft" change sets permanently, check out the top answer, which basically suggests doing:

hg strip 'roots(outgoing())'

这篇关于有什么办法可以删除Mercurial中的本地提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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