在推送之前先丢弃Mercurial中的本地分支机构 [英] Discard a local branch in Mercurial before it is pushed

查看:41
本文介绍了在推送之前先丢弃Mercurial中的本地分支机构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多时候,我在本地Hg存储库中提交的提交很少,我不想推送,有时我想完全删除本地分支.但是我不能回滚多个提交,这让我别无选择,只能创建一个新的克隆并再次下载整个存储库.这感觉很愚蠢,因为如果我可以删除我的本地分支(无论如何也不会影响远程存储库),那么我就不必创建和设置新的克隆.那么,这是Mercurial中的情况还是有某种丢弃本地分支的方法?

Many times it happens that I have few commits on my local Hg repository which I don't want to push and sometimes I want to remove the local branch altogether. But I cannot rollback more than one commit which leaves me no choice than creating a new clone and download the whole repository again. This feels stupid, since if I could just delete my local branch which has not affected the remote repository in anyway, then I wouldn't have to create and setup a new clone. So, is it how it is in Mercurial or is there some way to discard a local branch?

谢谢!

推荐答案

如果启用mq扩展名(与Mercurial捆绑在一起),则可以使用hg strip.但是请小心,因为这会修改存储库的历史记录.安全的方法是将您的存储库克隆到要创建的分支之前的修订版本,然后拉出要保留的其余变更集.

If you enable the mq extension (bundled with Mercurial), you can use hg strip. Be careful, though, as this will modify the history of your repository. The safe method is to clone your repository up to the revision preceding the creation of the branch you want to discard, then to pull the remaining changesets that you want to keep.

这篇关于在推送之前先丢弃Mercurial中的本地分支机构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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