简体   繁体   中英

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM