svn merge

Name

svn merge — Apply the differences between two sources to a working copy path.

Synopsis

svn merge sourceURL1[@N] sourceURL2[@M] [WCPATH]
svn merge sourceWCPATH1@N sourceWCPATH2@M [WCPATH]
svn merge [[-c M]... | [-r N:M]...] [SOURCE[@REV] [WCPATH]]

Description

In the first form, the source URLs are specified at revisions N and M. These are the two sources to be compared. The revisions default to HEAD if omitted.

In the second form, the URLs corresponding to the source working copy paths define the sources to be compared. The revisions must be specified.

In the third form, SOURCE can be either a URL or a working copy path (in which case its corresponding URL is used). If not specified, SOURCE will be the same as WCPATH. SOURCE in revision REV is compared as it existed between revisions N and M for each revision range provided. If REV is not specified, HEAD is assumed.

-c M is equivalent to -r <M-1>:M, and -c -M does the reverse: -r M:<M-1>. If no revision ranges are specified, the default range of 1:HEAD is used. Multiple -c and/or -r instances may be specified, and mixing of forward and reverse ranges is allowed—the ranges are internally compacted to their minimum representation before merging begins (which may result in no-op).

WCPATH is the working copy path that will receive the changes. If WCPATH is omitted, a default value of . is assumed, unless the sources have identical basenames that match a file within .. In this case, the differences will be applied to that file.

Subversion will internally track metadata about the merge operation only if the two sources are ancestrally related—if the first source is an ancestor of the second or vice versa. This is guaranteed to be the case when using the third form. Unlike svn diff, the merge command takes the ancestry of a file into consideration when performing a merge operation. This is very important when you're merging changes from one branch into another and you've renamed a file on one branch but not the other.

Alternate names

None

Changes

Working copy

Accesses repository

Only if working with URLs

Options

--accept ACTION
--change (-c) REV
--depth ARG
--diff3-cmd CMD
--dry-run
--extensions (-x) ARG
--force
--ignore-ancestry
--quiet (-q)
--record-only
--reintegrate
--revision (-r) REV

Examples

Merge a branch back into the trunk (assuming that you have an up-to-date working copy of the trunk):

$ 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.

To merge changes to a single file:

$ cd myproj
$ svn merge -r 30:31 thhgttg.txt 
U  thhgttg.txt