SVN - dealing with trunks, branching, making releases, merging, etc

Since I'm new to Subversion (SVN), and command line calls, here's some sample commands and good practice to branch off a trunk, make changes, merge (dry run), merge, then test, then commit.

For good site on SVN basics: http://svnbook.red-bean.com/nightly/en/index.html

  • app.karljay.com/svn - SVN host url
  • myapp - my application

    copy myapp trunk to branch ABC-123:

    svn cp https://app.karljay.com/svn/myapp/trunk https://app.karljay.com/svn/myapp/branches/ABC-123 -m "ABC-123 Branching off trunk"

    You can then work on the branch "ABC-123".

    After you're done, you'll need the revision number.

    So to get branch on your copy:

    svn log --stop-on-copy
    ------------------------------------------------------------------------
    r18132 | kgarcia | 2009-03-24 14:53:10 +0000 (Tue, 24 Mar 2009) | 1 line

    ABC-123 - add this enhancement, and fix other bugs
    ------------------------------------------------------------------------
    [kgarcia@karljay.com ABC-123]$ pwd
    /home/kgarcia/www/karljay.com/ABC-123

    To make a release branch "2009-04", copy trunk to branch:

    [kgarcia@karljay.com karljay.com]$ svn cp https://app.karljay.com/svn/myapp/trunk https://app.karljay.com/svn/myapp/branches/2009-04 -m "Branching off trunk for the April 2009 release"

    Committed revision 18239.

    After you're done and ready to merge back (to main trunk, or release), do a dry-run. This won't merge, but good to get statuses of files like U for updated, A for added, and C for conflict, which is what you'll watch out for.

    If you don't see any conflicts, great. So run the merge to merge the branch you want to merge INTO the checked out copy

    [kgarcia@karljay.com 2009-04]$ pwd
    /home/kgarcia/www/karljay.com/2009-04
    [kgarcia@karljay.com 2009-04]$ svn merge --dry-run -r18132:HEAD https://app/svn/myapp/branches/ABC-123

    A home/webmetrics_banner.php
    U home/dsp_home.php
    A images/kj_banner.gif
    U order/secondary/act_step5.php
    U order/karljay/act_step5.php
    U zone/dsp_zonelist.php

    When ready, remove the --dry-run to do the real thing.

    After testing it is good, commit:

    [kgarcia@karljay.com 2009-04]$ svn commit -m "ABC-123 Merged to April 2009 release branch"
    Sending home/webmetrics_banner.php
    Sending home/dsp_home.php
    Sending images/kj_banner.gif
    Sending order/secondary/act_step5.php
    Sending order/karljay/act_step5.php
    Sending zone/dsp_zonelist.php
    Transmitting file data ......
    Committed revision 18240.