SVN - some quick commands during merge

Posted by Shaaf's blog on Monday, August 25, 2008

Following are some of the frequently used svn commands during merging and branching. I used to work with tortoise for this but as soon as I learned these, it feels like a more easier space to be in. Although no points taken away from tortoise, it still works pretty good for the gui part, This article is more targeted towards dark screen lovers.

Create a new branch from trunk: If you want to create a branch from a specific revision of Trunk following command is handy. It does a remote copy. which means the machine you are on does not need a copy of the whole tree.


An example

	$ svn copy -r 1234 --username foo --password bar -m "Remote copy"

When was this branch created? If you want to know the day branch was created.

	$ svn log -v --stop-on-copy BRANCH_URL

The last record will show you the day the branch as created.

List all the branches: If you want to take a listing of branches or a tree

	$ svn ls BRANCHES_URL


Merge from Branch to Trunk:

Browse to where you have checkedout trunk in the local directory.

	$ cd

Update trunk to HEAD.

	$ svn update
At revision 1234.

Following will merge from branch to trunk but will not commit.


Branch_REVISION will be the revision branch was created if this is the first time you are doing the merge.

	$ svn merge -r 1233:1234

After this you should do an

svn status

to check the status of the files. the files will be marked with following Characters.

‘A’ Added ‘C’ Conflicted ‘D’ Deleted ‘I’ Ignored ‘M’ Modified

If there is any ‘C’ in the status the files will not be committed if you try an svn commit to save the merge to the trunk.

Merge from Trunk to Branch:

To merge from Trunk to branch you would need to browse to the branch checked out in the local direcotry.

$ cd
$ svn update
At revision 1234.

The following command will try merging trunk from revision 1233 i.e. the day branch was created to branch head.

$ svn merge -r 1233:HEAD TrunkURL BRANCH_URL

Hopefully this should help. However you should definitely refer to SVN Book for more detail.

svnbook at SVN Book