Tuesday, July 1, 2008

SVN Merge (Trunk to Branch)

Ever have code changes that need to be pushed into a branch? Or merged back into HEAD or the trunk?

Recently (today), I had the need to merge code changes from HEAD into a newly created branch. Given the fact that my changes spanned a couple of weeks (no lectures, please, as I was on vacation :D), I could not remember all of the lines that were changed in 9 files. I didn't want to blindly copy the files into the branch as I might (shouldn't really) overwrite another developers changes.

After a quick google search and a read of a short blog posting, I had found a quick path forward. For the same reasons that caused the Jake to write a blog, I'm also writing this so that I can easily find it.

I checked in my files into HEAD and got the revision number (7200). Then I changed directories to the directory of the branch and ran the following command:

svn merge -r 7199:7200 https://phlcvs01/svn/netcds/trunk .

If you want to preview the changes, specify '--dry-run' which causes SVN to list the changes that will occur. Using '-r 7199:7200' causes subversion to only grab the differences between those revisions. Upon executing the command, 'svn stat' shows the modified files that you need to check into the branch.

Simple and easy.