Mercurial 仅提交提示

发布于 2024-10-10 19:53:22 字数 156 浏览 4 评论 0原文

在我的设置中,我有一个中央 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

ㄟ。诗瑗 2024-10-17 19:53:22

你为什么要这么做?进行小的更改可以轻松地恢复某些内容。如果您在一次大提交中收集了所有内容,那么恢复一个小更改可能并不那么容易。

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.

深爱成瘾 2024-10-17 19:53:22

我同意比约恩的观点(并且我赞成他的回答),你所做的并不是一个好主意——有意义的历史是一件好事。如果无法说服您放弃它,那么您要做的不仅仅是推送最后一个变更集,而是推送一个由所有这些变更集组合而成的新变更集。最简单的方法是使用折叠扩展,尽管 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.

幽蝶幻影 2024-10-17 19:53:22

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.

友欢 2024-10-17 19:53:22

可以使用 mq 扩展重写您的历史记录。假设您要折叠的修订版本为转速 5、6、7,其中 7 为提示。您可以通过以下方式完成此操作:

# Import the revs you want to collapse into mq
# mq will create patches for each revision from 5:tip, with the name
# <local rev number>.diff
hg qimport -r5:tip
# Goto the first commit
hg qgoto 5.diff
# Fold in the other commits successively. Aside from shell magic, there is
# no command line way to specify multiple patches at once.
hg qfold 6.diff
hg qfold 7.diff
# Commit the new mq patch as a changeset of its own
hg qfinish 5.diff

现在,您的存储库仅包含修订版 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:

# Import the revs you want to collapse into mq
# mq will create patches for each revision from 5:tip, with the name
# <local rev number>.diff
hg qimport -r5:tip
# Goto the first commit
hg qgoto 5.diff
# Fold in the other commits successively. Aside from shell magic, there is
# no command line way to specify multiple patches at once.
hg qfold 6.diff
hg qfold 7.diff
# Commit the new mq patch as a changeset of its own
hg qfinish 5.diff

Now, your repository contains only a rev 5 with the contents of what was previously revisions 5, 6, and 7.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文