<?xml version="1.0" encoding="utf-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>svn merge</title> <link rel="stylesheet" type="text/css" href="styles.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <style type="text/css"> body { background-image: url('images/draft.png'); background-repeat: no-repeat; background-position: top left; /* The following properties make the watermark "fixed" on the page. */ /* I think that's just a bit too distracting for the reader... */ /* background-attachment: fixed; */ /* background-position: center center; */ }</style> <link rel="home" href="index.html" title="Version Control with Subversion [DRAFT]" /> <link rel="up" href="svn.ref.svn.html" title="svn Reference—Subversion Command-Line Client" /> <link rel="prev" href="svn.ref.svn.c.log.html" title="svn log" /> <link rel="next" href="svn.ref.svn.c.mergeinfo.html" title="svn mergeinfo" /> </head> <body> <div xmlns="" id="vcws-version-notice"> <p>This text is a work in progress—highly subject to change—and may not accurately describe any released version of the Apache™ Subversion® software. Bookmarking or otherwise referring others to this page is probably not such a smart idea. Please visit <a href="http://www.svnbook.com/">http://www.svnbook.com/</a> for stable versions of this book.</p> </div> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">svn merge</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="svn.ref.svn.c.log.html">Prev</a> </td> <th width="60%" align="center">svn Reference—Subversion Command-Line Client</th> <td width="20%" align="right"> <a accesskey="n" href="svn.ref.svn.c.mergeinfo.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="svn merge"> <a id="svn.ref.svn.c.merge"></a> <div class="titlepage"></div> <a id="idp20633888" class="indexterm"></a> <div class="refnamediv"> <h2>Name</h2> <p>svn merge — Apply the differences between two sources to a working copy path.</p> </div> <div class="refsynopsisdiv" title="Synopsis"> <h2>Synopsis</h2> <p> <code class="literal">svn merge SOURCE[@REV] [TARGET_WCPATH]</code> </p> <p> <code class="literal">svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]</code> </p> <p> <code class="literal">svn merge SOURCE1[@N] SOURCE2[@M] [TARGET_WCPATH]</code> </p> </div> <div class="refsect1" title="Description"> <a id="idp20640288"></a> <h2>Description</h2> <p>In all three forms <em class="replaceable"><code>TARGET_WCPATH</code></em> is the working copy path that will receive the differences. If <em class="replaceable"><code>TARGET_WCPATH</code></em> 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 file.</p> <p>In the first two forms, <em class="replaceable"><code>SOURCE</code></em> can be either a URL or a working copy path (in which case its corresponding URL is used). If the peg revision <em class="replaceable"><code>REV</code></em> is not specified, then <code class="literal">HEAD</code> is assumed. In the third form the same rules apply for <em class="replaceable"><code>SOURCE1</code></em>, <em class="replaceable"><code>SOURCE2</code></em>, <em class="replaceable"><code>M</code></em>, and <em class="replaceable"><code>N</code></em> with the only difference being that if either source is a working copy path, then the peg revisions <span class="emphasis"><em>must</em></span> be explicitly stated.</p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p>Automatic Merges</p> <p>The first form is called an <span class="quote">“<span class="quote">automatic merge</span>”</span> and is used to perform <span class="quote">“<span class="quote">sync</span>”</span> and <span class="quote">“<span class="quote">reintegrate</span>”</span> merges. <span class="quote">“<span class="quote">Sync</span>”</span> merges merge eligible changes to a branch (<em class="replaceable"><code>TARGET_WCPATH</code></em>) from the branch's ancestor branch (<em class="replaceable"><code>SOURCE</code></em>). <span class="quote">“<span class="quote">Eligible</span>”</span> changes are defined as those that were not previously merged from (<em class="replaceable"><code>SOURCE</code></em>) to (<em class="replaceable"><code>TARGET_WCPATH</code></em>). See <a class="xref" href="svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.stayinsync" title="Keeping a Branch in Sync">the section called “Keeping a Branch in Sync”</a>. <span class="quote">“<span class="quote">Reintegrate</span>”</span> merges merge changes from a feature branch (<em class="replaceable"><code>SOURCE</code></em>) back into the feature branch's ancestor branch (<em class="replaceable"><code>TARGET_WCPATH</code></em>), see <a class="xref" href="svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.reintegrate" title="Reintegrating a Branch">the section called “Reintegrating a Branch”</a> and <a class="xref" href="svn.branchmerge.commonpatterns.html#svn.branchmerge.commonpatterns.feature" title="Feature Branches">the section called “Feature Branches”</a>. </p> </li> <li class="listitem"> <p>Cherrypick Merges</p> <p>The second form is called a <span class="quote">“<span class="quote">cherry-pick</span>”</span> merge and is used to merge an explicitly defined set of changes from one branch to another. <em class="replaceable"><code>SOURCE</code></em> in revision <em class="replaceable"><code>REV</code></em> is compared as it existed between revisions <em class="replaceable"><code>N</code></em> and <em class="replaceable"><code>M</code></em> for each revision range provided. See <a class="xref" href="svn.branchmerge.advanced.html#svn.branchmerge.cherrypicking" title="Cherrypicking">the section called “Cherrypicking”</a> for more information.</p> <div class="tip" title="Tip" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Tip"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Tip]" src="images/tip.png" /> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>Multiple <code class="literal">-c</code> and/or <code class="literal">-r</code> 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 a no-op merge or conflicts that cause the merge to stop before merging all of the requested revisions).</p> </td> </tr> </table> </div> </li> <li class="listitem"> <p>2-URL Merges</p> <p>In the third form, called a <span class="quote">“<span class="quote">2-URL Merge</span>”</span>, the difference between <em class="replaceable"><code>SOURCE1</code></em> at revision <em class="replaceable"><code>N</code></em> and <em class="replaceable"><code>SOURCE2</code></em> at revision <em class="replaceable"><code>M</code></em> is generated and applied to <em class="replaceable"><code>TARGET_WCPATH</code></em>. The revisions default to <code class="literal">HEAD</code> if omitted.</p> </li> </ul> </div> <p>If <a class="xref" href="svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.mergetracking" title="Merge Tracking">Merge Tracking</a> is active, then Subversion will internally track metadata (i.e. the <code class="literal">svn:mergeinfo</code> 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.</p> <p>Unlike <span class="command"><strong>svn diff</strong></span>, 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.</p> <div class="tip" title="Tip" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Tip"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Tip]" src="images/tip.png" /> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The <code class="option">--ignore-ancestry</code> option will cause <a class="xref" href="svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.mergetracking" title="Merge Tracking">Merge Tracking</a> to be disabled and makes merge act like <span class="command"><strong>svn diff</strong></span>, ignoring the ancestry of files when merging.</p> </td> </tr> </table> </div> </div> <div class="refsect1" title="Options"> <a id="idp20675504"></a> <h2>Options</h2> <div class="informalexample"> <pre class="screen"> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.accept"><code class="option">--accept</code> <em class="replaceable"><code>ACTION</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.allow_mixed_revisions"><code class="option">--allow-mixed-revisions</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.change"><code class="option">--change</code> (<code class="option">-c</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.depth"><code class="option">--depth</code> <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.diff3_cmd"><code class="option">--diff3-cmd</code> <em class="replaceable"><code>CMD</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.dry_run"><code class="option">--dry-run</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.extensions"><code class="option">--extensions</code> (<code class="option">-x</code>) <em class="replaceable"><code>ARG</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.force"><code class="option">--force</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.ignore_ancestry"><code class="option">--ignore-ancestry</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.quiet"><code class="option">--quiet</code> (<code class="option">-q</code>)</a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.record_only"><code class="option">--record-only</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.reintegrate"><code class="option">--reintegrate</code></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.revision"><code class="option">--revision</code> (<code class="option">-r</code>) <em class="replaceable"><code>REV</code></em></a> <a class="xref" href="svn.ref.svn.html#svn.ref.svn.sw.verbose"><code class="option">--verbose</code> (<code class="option">-v</code>)</a> </pre> </div> </div> <div class="refsect1" title="Examples"> <a id="idp20687376"></a> <h2>Examples</h2> <p>Reintegrate a branch back into the trunk—assuming that you have an up-to-date working copy of the trunk (the <code class="option">--verbose</code> 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):</p> <div class="informalexample"> <pre class="screen"> $ 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. </pre> </div> <p>Cherry-pick merge a single change to a file:</p> <div class="informalexample"> <pre class="screen"> $ 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 </pre> </div> <p>Merge the differences between two unrelated branches into a third branch:</p> <div class="informalexample"> <pre class="screen"> $ 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 </pre> </div> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="svn.ref.svn.c.log.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="svn.ref.svn.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="svn.ref.svn.c.mergeinfo.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">svn log </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> svn mergeinfo</td> </tr> </table> </div> <div xmlns="" id="vcws-footer"> <hr /> <img src="images/cc-by.png" style="float: right;" /> <p>You are reading <em>Version Control with Subversion</em> (for Subversion 1.8), by Ben Collins-Sussman, Brian W. Fitzpatrick, and C. Michael Pilato.</p> <p>This work is licensed under the <a href="http://creativecommons.org/licenses/by/2.0/">Creative Commons Attribution License v2.0</a>.</p> <p>To submit comments, corrections, or other contributions to the text, please visit <a href="http://www.svnbook.com/">http://www.svnbook.com/</a>.</p> </div> </body> </html>