I generally use git-svn for my work on WordPress and related projects. On occasion, I’m forced to touch svn
directly. This occurs most often when merging commits from trunk to a stable branch: it’s best to do this in a way that preserves svn:mergeinfo
, and git-svn
doesn’t do it properly. Nearly every time I have to do these merges, I have to relearn the process. Here’s a reminder for Future Me.
- Commit as you normally do to trunk. Make note of the revision number. (Say, 36040.)
- Create a new svn checkout of the branch, or
svn up
your existing one. Eg:$ svn co https://develop.svn.wordpress.org/branches/4.4 /path/to/wp44/
- From within the branch checkout:
$ svn merge -c 36040 ^/trunk
In other words: merge the specific commit (or comma-separated commits) from trunk of the same repo. - This will leave you with a dirty index (or whatever svn calls it). Use
svn status
to verify. Run unit tests, etc. $ svn ci
. Copy the trunk commit message to EDITOR, and add a line along the lines of “Merges [36040] to the 4.4 branch”- Drink 11 beers.
Nacin made this into a shell script ages ago: https://gist.github.com/johnbillion/22dcc4ae736a3e8d022c
Usage example:
cd branches/4.4
../merge.sh 12345
svn ci
Paste your clipboard contents into the commit message, tweak it, save and quit
Oh! Thanks for that, John.