将最近的提交放在 Mercurial (Hg) 的单独(命名)分支中

发布于 2024-11-04 23:44:46 字数 182 浏览 1 评论 0原文

如果自上次推送以来我对默认分支进行了多次提交,是否可以返回并将这些提交移动到单独的命名分支中?

也就是说,我有:

A--B--C--D

并且我想要:

A
 \
  B--C--D

我希望这有意义吗?

If I have several commits made to the default branch since the last push, is it possible to go back, and move those commits into a separate named branch?

That is, I have:

A--B--C--D

and I want:

A
 \
  B--C--D

I hope this makes sense?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

盗心人 2024-11-11 23:44:46

查看 Transplant 扩展。

但就我个人而言,我会使用 MQ 来完成此操作,如下所示:

# assuming revs 1 and 2 are the ones we want to move
hg qimport -r1:2

# qimport creates a patch for each changeset
>hg qapplied
1.diff
2.diff

# pop the patches, to save for later
>hg qpop -a
popping 2.diff
popping 1.diff
patch queue now empty

# switch branches
>hg branch my-branch
marked working directory as branch my-branch

# push our saved changesets, essentially rebasing on the new branch
>hg qpush -a
applying 1.diff
applying 2.diff
now at: 2.diff

# make the patches part of permanent history
>hg qfin -a

您也可以弯曲 Rebase如果您愿意,可以扩展以适应此目的。

Take a look at the Transplant extension.

But personally, I'd do it using MQ, like so:

# assuming revs 1 and 2 are the ones we want to move
hg qimport -r1:2

# qimport creates a patch for each changeset
>hg qapplied
1.diff
2.diff

# pop the patches, to save for later
>hg qpop -a
popping 2.diff
popping 1.diff
patch queue now empty

# switch branches
>hg branch my-branch
marked working directory as branch my-branch

# push our saved changesets, essentially rebasing on the new branch
>hg qpush -a
applying 1.diff
applying 2.diff
now at: 2.diff

# make the patches part of permanent history
>hg qfin -a

You could probably also bend the Rebase extension to suit this purpose, if you prefer.

若沐 2024-11-11 23:44:46

如果提交仍然仅在您的本地存储库中并且尚未推送到任何其他存储库,那么是的,您可以以相当小的麻烦重新安排它们。但是,如果他们的范围超出了您的本地存储库,您将遇到很多麻烦。

要重新安排提交,您需要使用 MQ 扩展。 这是一个教程,因为它比我在这里能更好地解释事情。

If the commits are still in only your local repository and have not been pushed to any other one, then yes, you can re-arrange them with fairly minimal trouble. If they have moved beyond just your local repo, however, you will run into a lot of trouble.

To re-arrange commits, you want to use the MQ extension. Here's a tutorial, since it explains things better than I could here.

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