svn merge — Apply the differences between two sources to a working copy path.
svn merge SOURCE[@REV] [TARGET_WCPATH]
svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]
svn merge SOURCE1[@N] SOURCE2[@M] [TARGET_WCPATH]
In all three forms
the working copy path that will receive the differences. If
TARGET_WCPATH is omitted, the
changes are applied to the current working directory,
unless the sources have identical basenames that match a
file within the current working directory. In
that case, the differences will be applied to that
In the first two forms,
can be either a URL or a working copy path (in which case its
corresponding URL is used). If the peg revision
REV is not specified, then
HEAD is assumed. In the third form the
same rules apply for
with the only difference being that if either source is a
working copy path, then the peg revisions
must be explicitly stated.
The first form is called an “automatic merge” and is used to perform “sync” and “reintegrate” merges. “Sync” merges merge eligible changes to a branch (
TARGET_WCPATH) from the branch's ancestor branch (
SOURCE). “Eligible” changes are defined as those that were not previously merged from
TARGET_WCPATH. See the section called “Keeping a Branch in Sync”. “Reintegrate” merges merge changes from a feature branch (
SOURCE) back into the feature branch's ancestor branch (
TARGET_WCPATH), see the section called “Reintegrating a Branch” and the section called “Feature Branches”.
The second form is called a “cherry-pick” merge and is used to merge an explicitly defined set of changes from one branch to another.
REVis compared as it existed between revisions
Mfor each revision range provided. See the section called “Cherrypicking” for more information.Tip
-rinstances 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 a no-op merge or conflicts that cause the merge to stop before merging all of the requested revisions).
In the third form, called a “2-URL Merge”, the difference between
Mis generated and applied to
TARGET_WCPATH. The revisions default to
is active, then Subversion will internally track metadata
svn:mergeinfo property) about
merge operations when the two merge 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 performing automatic merges. Subversion will also take
preexisting merge metadata on the working copy target into
account when determining what revisions to merge and in an
effort to avoid repeat merges and needless conflicts it may
only merge a subset of the requested ranges.
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.
--ignore-ancestry option will cause
to be disabled and makes merge act like
svn diff, ignoring the ancestry of files
Reintegrate a branch back into the trunk—assuming
that you have an up-to-date working copy of the trunk (the
--verbose option prints additional
information regarding what the merge is doing prior to
actually applying any diff; useful in very large which
might take a significant amount of time to complete):
$ svn merge ^/branches/feature-branch-calc-enhancements trunk --verbose checking branch relationship... calculating automatic merge... merging... --- Merging r12 through r37 into 'trunk': U trunk/calc/brush.c --- Recording mergeinfo for merge of r12 through r37 into 'trunk': U trunk $ # build, test, verify, ... $ svn commit trunk -m "Reintegrate the calc enhancements back to trunk!" Sending trunk Sending trunk/calc/brush.c Transmitting file data . Committed revision 38.
Cherry-pick merge a single change to a file:
$ svn merge ^/trunk/calc/brush.c branches/1.x/calc/brush.c -c38 --- Merging r38 into 'branches/1.x/calc/brush.c': U branches/1.x/calc/brush.c --- Recording mergeinfo for merge of r38 into 'branches/1.x/calc/brush.c': G branches/1.x/calc/brush.c
Merge the differences between two unrelated branches into a third branch:
$ svn merge ^/vendor-drop/vendor-1.0 ^/vendor-drop/vendor-1.1 \ trunk --ignore-ancestry --- Merging differences between repository URLs into 'trunk': U trunk/draw/draw.py