开发者

merge 2 svn branches together

开发者 https://www.devze.com 2023-01-30 03:43 出处:网络
I\'m working with an svn setup I\'m not used to and I need to merge new code from one branch to another.

I'm working with an svn setup I'm not used to and I need to merge new code from one branch to another.

There's no code in the trunk folder so I don't know if I should update the trunk to 开发者_开发问答the code and update the second branch, OR if there is a way to just update one branch to the other. My last resort is going to be just updating the code manually.

Any ideas what the best route here is? I'm doing everything from a terminal.


No Don't update manually. Of course the difficulty will depend on how close those branches are.

You can always bring changes from a branch to another branch. Let's say you have two branch named branch1 and branch2 and you want to merge branch2 to branch1.

Say you are in branch1 (Try the dry run first to see if it results in conflicts)

svn merge -r LAST_MERGED_REVISION:HEAD_REVISION --dry-run url/to/branches/branch2 .

svn merge -r LAST_MERGED_REVISION:HEAD_REVISION url/to/branches/branch2 .
svn status | egrep '^C|^.C' <---Manual intervention is required for conflicts
svn update
svn ci -m "Merge changes from branch2"

And you can close out branch2

svn merge --reintegrate url/to/branches/branch2
svn update
svn ci -m "Merged branch2 to branch1"

This may fail in case the branches are very divergent.


Depending on what subversion release you are using, I recommend to use svnmerge, or subversion's builtin merge tracking support. In any case, it is well possible to merge from one branch to another, without using the trunk (assuming that the branches have some relatively-close ancestor).

0

精彩评论

暂无评论...
验证码 换一张
取 消