14

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)
animuson
  • 53,861
  • 28
  • 137
  • 147
Q Boiler
  • 1,187
  • 9
  • 20

2 Answers2

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

sbi
  • 219,715
  • 46
  • 258
  • 445
  • This worked. I did not need the backup, but it was good to have as you don't want to loose several days worth of work. I like the svn mantra! – Q Boiler May 25 '10 at 16:56
2

To be very careful, I'd commit my changes to a private branch (let's call it C), then merge the C branch to the new open-for-commits branch B.

  1. cd to working directory with changes you want to commit
  2. svn copy . C
  3. cd .. to your workspace folder with checkouts
  4. svn co B
  5. cd into B directory
  6. svn merge the revision from step 2.
  7. Review changes.
  8. Commit!
sbi
  • 219,715
  • 46
  • 258
  • 445
Taylor
  • 510
  • 6
  • 14