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 wou开发者_JAVA百科ld like to commit my working copy changes (currently pointing at Branch A into branch B without commiting to Branch A)
- Make backup of your working copy.
svn switch
to branchB
- review changes (base revision might differ, and svn does blind, dumb textual merges only), resolve conflicts, if any
- 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
.
cd
to working directory with changes you want to commitsvn copy . C
cd ..
to your workspace folder with checkoutssvn co B
cd
into B directorysvn merge
the revision from step 2.- Review changes.
- Commit!
精彩评论