Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I merge two SVN branches?

Tags:

merge

svn

I have two SVN branches checked out, "b1" and "b2". I would like to merge all of my commits from the "b1" branch onto the "b2" branch. I have tried something like

svn merge -r HEAD:HEAD b1 b2

but it does nothing. I am sure I have this command wrong, but I can't find good documentation on it. I would like to do this on the client side and not create a third branch.

I am using SVN 1.4.4 which doesn't support the reintegrate option.

How can I do it?

like image 590
Tony Avatar asked Sep 03 '09 04:09

Tony


People also ask

Can we merge two branches in SVN?

In the From URL option, you should specify the branch to which you want to merge. For example, assume that there are 2 branches, branch A and branch B , and you want to merge branch B to branch A . In TortoiseSVN, click on Merge option and then select Merge two different trees option.

How do I merge two SVN branches in eclipse?

Merging means creating a version by blending different revisions of resources. To start merging click 'Team>Merge...' menu item of the resource pop-up menu, 'Merge...' menu item of the SVN main menu group or on the 'Merge...' button on the 'SVN Toolbar'.


2 Answers

Your problem is with the -r flag. You have to specify a range of revisions. So for example:

svn merge -r 13:HEAD b1 b2

To figure out the correct revision number you can do:

svn log --stop-on-copy b1

log will then only list commits which happened on b1. The smallest revision number you'll see will be your pick.

I've never used this form though. I always ensured that I was actively on branch b2, and then did:

svn merge -r 13:HEAD url://to/branch/b1
like image 65
exhuma Avatar answered Oct 15 '22 10:10

exhuma


From the reference page for svn merge in the Subversion book:

$ svn merge --reintegrate \
            http://svn.example.com/repos/calc/branches/my-calc-branch
--- Merging differences between repository URLs into '.':
U    button.c
U    integer.c
U    Makefile
 U   .

$ # build, test, verify, ...

$ svn commit -m "Merge my-calc-branch back into trunk!"
Sending        .
Sending        button.c
Sending        integer.c
Sending        Makefile
Transmitting file data ..
Committed revision 391.

Edit: OK, so you're using an old version of Subversion. In that case, see Merging a Whole Branch to Another in version 1.4 of the book.

like image 26
Daniel Pryden Avatar answered Oct 15 '22 09:10

Daniel Pryden