How do I merge two SVN branches?

31,577

Solution 1

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

Solution 2

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.

Share:
31,577
Abhinav Kaushal Keshari
Author by

Abhinav Kaushal Keshari

Updated on January 04, 2020

Comments

  • Abhinav Kaushal Keshari
    Abhinav Kaushal Keshari over 4 years

    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?