Today I had a big SVN merge to do - i'm at the end of a development cycle and I needed to merge my branch of changes back into trunk. I dug out my crib sheet for merging and tweeted that I had - and a few people asked me to blog it so here it is.
diff the relevant paths until the + and - shoe the operations you want to perform to your working copy
change into the equivalent directory on your working copy and replace the word "diff" with the word "merge"
Seems like a bit of a short blog post for something that a lot of people find painful, so here's what I actually did, in more depth.
- I had the branch I'd been working on checked out. I committed all changes and triple-checked that I had done that
- I ran
svn log --stop-on-copyand noted the revision number which was the commit where I created the branch
- Next I took a checkout of trunk so that I could break things in my own space
- I changed into the new checkout and from the root of it, figured out what I should be diffing, piped it to more and read through the output to make sure I really was applying what I thought I was applying.
svn diff -r[branch create rev]:HEAD http://path/to/repo/branch/ | more
- Then I ran the same command again but without the |more and with diff now replaced by merge
- I then checked my working copy, if there were conflicts I'd have resolved them, checked the system still worked, that sort of thing
- Committed my changes
I hope that helps - the same principle applies whether you are applying one fix or many fixes to trunk or branches - the key is to think about what it is you want to merge, and make sure the diff looks right. You can play with the diff without breaking anything for as long as you need to (which today was just as well because the first thing I tried was completely not the right one!) and once it looks plausible - merge those changes in and then untangle anything which has gone wrong from there. Hope this helps!