如何正确合并两个 bzr 分支?
我与同一项目的两个分支合作。它们都是我几个月前创建的。我是这个项目的唯一开发者。经过很长一段时间的忽视后,我又回到了这个项目。
我最初的意图(据我记得两年前我的想法)是拥有一个没有工作树的单一(共享)存储库,并拥有主干分支以及几个实验分支(根据需要)。我最终得到了两个分支 - 第一个是“生产分支”,第二个是为了测试实验功能而创建的。 以下是在两个分支内发出的 bzr info
的输出:
分支 1
C:\My\Proj\path\qwerty>bzr info
Lightweight checkout (format: 2a)
Location:
light checkout root: .
checkout of branch: C:/My/Proj/path/qwertyBazaarRepo/trunk
shared repository: C:/My/Proj/path/qwertyBazaarRepo
Related branches:
parent branch: .
submit branch: C:/My/Proj/path/ExperimentalQwerty
C:\My\Proj\path\qwerty>
分支 2
C:\My\Proj\path\ExperimentalQwerty>bzr info
Standalone tree (format: 2a)
Location:
branch root: .
Related branches:
parent branch: C:/My/Proj/path/qwertyBazaarRepo/trunk
submit branch: C:/My/Proj/path/qwertyBazaarRepo/trunk
我想合并两个分支的多个文件(以便它们在所有这两个分支和任何后续分支中变得相同) 。这样做的最佳方法是什么?
PS 为了对更改/合并进行目视检查,我想使用 kdiff3
I work with two branches of the same project. Both of them were created by me many months ago. I am the only developer of this project. I return to this project after a long period of neglect.
My original intent (as far as I remember what I had on my mind ~2 years ago) was to have a single (shared) repository without working trees and have the main trunk branch as well as several experimental ones (as needed). I ended up with two branches - the first one is the "production branch" and the second one was created to test experimental features.
Following are the outputs of bzr info
issued inside the two branches:
Branch 1
C:\My\Proj\path\qwerty>bzr info
Lightweight checkout (format: 2a)
Location:
light checkout root: .
checkout of branch: C:/My/Proj/path/qwertyBazaarRepo/trunk
shared repository: C:/My/Proj/path/qwertyBazaarRepo
Related branches:
parent branch: .
submit branch: C:/My/Proj/path/ExperimentalQwerty
C:\My\Proj\path\qwerty>
Branch 2
C:\My\Proj\path\ExperimentalQwerty>bzr info
Standalone tree (format: 2a)
Location:
branch root: .
Related branches:
parent branch: C:/My/Proj/path/qwertyBazaarRepo/trunk
submit branch: C:/My/Proj/path/qwertyBazaarRepo/trunk
I would like to merge several files of the two branches (so that they become identical in all these two and any subsequent branches). What is the best approach of doing this?
P.S. For visual examination of the changes/merges I would like to use kdiff3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,您的第一个位置是分支
C:/My/Proj/path/qwertyBazaarRepo/trunk
的轻量级检出,它确实使用共享存储库。第二个位置是独立分支。要比较 2 个分支的历史记录,请使用
bzr Missing path/to/other/branch
命令或bzr qlog path/to/branch1 path/to/branch2
。如果您不想合并历史记录,而只想合并更改,那么您可以直接在 2 棵树上使用 kdiff3 并手动合并更改,或者使用 bzr merge path/to/file 命令来合并各个文件,从主干分支(第一个位置)运行
merge
。要合并多个文件的更改,您可以多次运行
bzr merge FILE
,而无需在每次合并后提交,但对于所有后续合并,您必须使用--force
命令行选项,即bzr merge --force FILE
。此外,您可以在合并后使用
bzr shelve
删除您不希望出现的更改。Actually your 1st location is lightweight checkout of branch
C:/My/Proj/path/qwertyBazaarRepo/trunk
and it indeed uses shared repository. The second location is standalone branch.To compare history of 2 branches use either
bzr missing path/to/other/branch
command orbzr qlog path/to/branch1 path/to/branch2
.If you don't want to merge history, but only changes, then you can use either kdiff3 directly on 2 trees and manually merge changes, or use
bzr merge path/to/file
command to merge individual files, runmerge
from your trunk branch (1st location).To merge changes from several files, you can run
bzr merge FILE
several times without committing after each merge, but for all subsequent merges you must use--force
command-line option, i.e.bzr merge --force FILE
.Also, you can use
bzr shelve
after merge to remove changes you don't want to be there.