Mercurial 仅提交提示
在我的设置中,我有一个中央 Hg 存储库,我正在将本地更改推送到其中。假设在我的本地克隆中,我有一系列本地提交,然后我想将更改推送到中央存储库。我怎样才能只推送最终状态而不包括我所做的所有“小”本地提交?
我想要这个是因为有时我不想用我所做的所有小的本地提交来污染中央存储库的历史。
In my setup I have a central Hg repo to which I'm pushing my local changes. Say in my local clone I have a series of local commits and then I want to push the changes to the central repo. How can I push only the final state without including all of the "small" local commits that I made?
I want this because sometimes I dont want to pollute the central repo's history with all of the small local commits that I made.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你为什么要这么做?进行小的更改可以轻松地恢复某些内容。如果您在一次大提交中收集了所有内容,那么恢复一个小更改可能并不那么容易。
Why would you want to do that? Committing small changes makes it easy to revert something. If you collect everything in one big commit, reverting a small change might not be as easy.
我同意比约恩的观点(并且我赞成他的回答),你所做的并不是一个好主意——有意义的历史是一件好事。如果无法说服您放弃它,那么您要做的不仅仅是推送最后一个变更集,而是推送一个由所有这些变更集组合而成的新变更集。最简单的方法是使用折叠扩展,尽管 mq 甚至导出/导入都可以做到这一点。关键在于,在将多个变更集合并为一个变更集时,您将重写历史记录,并且将删除现有的变更集并将其替换为新的组合变更集。这样做违反了历史的不变性,而历史的不变性使得 Mercurial 如此值得信赖。
I agree with bjorn (and I'm upvoting his answer), what you're doing isn't a great idea -- meaningful history is a good thing. If you can't be talked out of it then what you're trying to do isn't just push the last changeset but a new changeset that is a combination of all those changesets. The easiest way to do that is to use the collapse extension, though mq or even export/import can do it. The key there is that in collapsing multiple changesets into one you're rewriting history and you're going to remove your existing changesets and replace them with that new combined changeset. Doing so violates the immutability of history that makes Mercurial so trust worthy.
Mercurial wiki 页面 ConcatenatingChangesets 中解释了如何在没有任何扩展的情况下执行此操作。
该页面还链接到一些带有 hg 扩展的替代方法,例如 CollapseExtension。
How to do this without any extensions is explained in the mercurial wiki page ConcatenatingChangesets.
That page also links to a few alternative approaches with hg extensions, like the CollapseExtension.
可以使用 mq 扩展重写您的历史记录。假设您要折叠的修订版本为转速 5、6、7,其中 7 为提示。您可以通过以下方式完成此操作:
现在,您的存储库仅包含修订版 5,其中包含先前修订版 5、6 和 7 的内容。
It is possible to rewrite your history using the mq extension. Suppose the revisions you want to collapse are revs, 5,6,7 with 7 being the tip. You would accomplish this via:
Now, your repository contains only a rev 5 with the contents of what was previously revisions 5, 6, and 7.