svnmergeworking-copy

SVN Working Copy to Different Branch Merge Without Commit to Working Copy Branch


If a working copy (local copy) was created from a branch, lets call it A. Coding was done in branch A, but branch A was "Closed" to commits, and branch b was opened. How do I merge my working copy changes into Branch B and commit to branch B, without commiting my changes to branch A first.

Trunk -> branch A.

   I checked out branch A and made changes.
   Branch A was closed to commits.

New Branch created from branch A. branch A -> branch B.

   I would like to commit my working copy changes (currently pointing at Branch A into branch B without commiting to Branch A)

Solution

    1. Make backup of your working copy.
    2. svn switch to branch B
    3. review changes (base revision might differ, and svn does blind, dumb textual merges only), resolve conflicts, if any
    4. commit

    Doing things like this with a working copy with uncommitted changes is perilous. If anything goes wrong or if there are too many conflicting changes, rollback to your backed up version, create a temporary branch from your working copy's base revision of A, switch to that, and commit your changes, so they are somewhere safe. Then merge that branch into B whichever way you want and delete it afterwards.

    Remember the svn mantra: Commit early, commit often. If I have uncommitted changes lying around for more than one workday, I get nervous. Usually, I create a feature branch for any development lasting longer than a few hours. and regularly commit to that. When I'm done I merge it into wherever it came from and delete it afterwards.