简体   繁体   English

Mercurial - 是否有可能在同一个回购中将更改从主干合并到分支?

[英]Mercurial - Is it possible to merge changes from the trunk to a branch, within the same repo?

Mercurial - Is it possible to merge changes from the trunk to a branch, within the same repository? Mercurial - 是否可以在同一个存储库中将更改从主干合并到分支?

If yes, is it possible with TortoiseHg? 如果是,是否可以使用TortoiseHg?

There are two things you can do, merge or transplant. 你可以做两件事,合并或移植。 These answers assume the command line, you may have to search through your menus in tortoise to find similar functionality. 这些答案假定命令行,您可能需要搜索乌龟中的菜单以查找类似的功能。

You can merge all the changes from one branch to another. 您可以将所有更改从一个分支合并到另一个分支。 The procedure for this is: 这个过程是:

hg update mybranch
hg merge default
hg commit -m "Merging with default"

This will bring all commits from default into your branch, but not the other way around. 这会将所有提交从默认提交到您的分支,但不是相反。 Later you can reintegrate your branch with default by doing the opposite 稍后您可以通过相反的方式重新集成您的分支

hg update default
hg merge mybranch
hg commit -m "Bringing in changes from mybranch"

If you want to bring in one or more specific commits that were committed in another branch, you can do that with 'transplant', which is a mercurial extension. 如果你想引入一个或多个在另一个分支中提交的特定提交,你可以使用'移植'来实现,这是一个多变的扩展。

# reqiured in ~/.hgrc
[extensions]
transplant = 

These are the commands you can use to use transplant: 这些是您可以用来使用移植的命令:

hg log | less
# (find revision number, the part after the colon, i.e. "88660cca467d")
hg update mybranch
hg transplant 88660cca467d
# (no commit required)

As @Jerub said, you can use merge and transplant to get change sets from one branch to another. 正如@Jerub所说,您可以使用合并和移植来从一个分支到另一个分支获取更改集。 With TortoiseHg you can do a merge by opening the "repository explorer", then select the first revision to merge, and afterwards right click on the second revision to merge. 使用TortoiseHg,您可以通过打开“repository explorer”进行合并,然后选择要合并的第一个修订版,然后右键单击要合并的第二个修订版。 Chose the "Merge with..." menu item to do the merge. 选择“Merge with ...”菜单项进行合并。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM