Reputation: 4943
I have a rather poorly planned subversion repository. And I want to begin making branches. Actually what I really want are "named" known good versions that I can go back to if need be. It seems this is done with svn branches.
The problem is that I never setup my subversion repository with any decent organization. I have no repository/trunk, repository/branches structure. Everything is in my repository root and the only commands I've executed are add, delete, mv, and ci. Now that I've reached a milestone, I want to label or branch it.
Given I've done no organization, how do I now build branches into my repository in order to execute a command like?
svn cp svn://server.com/svn/repository/trunk \
svn://server.com/svn/repository/branches/your_branch \
-m "Branching from trunk to your_branch at HEAD_REVISION"
Also, since my source code is at the root of my svn repository. Is any house keeping or good practices advised? Do I do this on the client side or server side?
Beginner question. Please provide svn commands and examples.
Upvotes: 0
Views: 949
Reputation: 3381
What Andy said
Given that everything is at the root of your repository, it looks to me like the best idea would be to start with a new repository, create the standard trunk/ branches/ tags/ folders at the root, copy the project to trunk/, tag it, and then carry on with the new repository.
From then on use tags (not branches) for naming releases. Branches are for when someone needs to work on a tricky problem in isolation, or do some experimental work, or if there are many changes that need peer reviewing and you don't want to hold back the rest of the team. Typically people work on branches for a bit then they are merged back with the trunk, at some stage. Tags instead never change.
#make a copy of the code - cleaning up all the hidden .svn directories
cd /pth/to/original/code
find . \! \( -name . -or -name ".svn" -or -path "*/.svn/*" \) -print | cpio -padv /pth/to/where/you/want/your/copy
#on svn server, create new repository
svnadmin create /path/to/svn/new_repo
svn mkdir /path/to/svn/new_repo/trunk -m "add a comment"
svn mkdir /path/to/svn/new_repo/branches -m "add a comment"
svn mkdir /path/to/svn/new_repo/tags -m "add a comment"
#import the code into the new repository
svn import -m "Start again" /pth/to/where/you/want/your/copy http://svn.example.com/new_repo/trunk
#tag the initial milestone
svn cp http://svn.example.com/new_repo/trunk http://svn.example.com/new_repo/tags/my_milestone -m "Release 1.0"
You may want to use semantic versioning for my_milestone, e.g. 1.0.0 and so on
Upvotes: 0
Reputation: 2993
You should probably look into tags for named versions instead of branches:
http://svnbook.red-bean.com/en/1.1/ch04s06.html
If your repository only contains code that relates to one application / project, then it would be a good idea to create a trunk directory and move everything you currently have into it. Then on the root level create a tags directory (for tags) and a branches directory (for branches). This can all be done on the client side (if you don't mind extra versions).
As for examples, I can't tell you the exact commands and syntax, but here's a quick outline to do this from the client side:
This should be very simple if you have an SVN client like TortoiseSVN.
Upvotes: 4