Eclipse project with Subclipse: Introduce trunk and branches
I have a project in my workspace (without trunk and branches) and need to create a copy of the current release for providing bug fixes for this release while working on a new feature, as described here: http://nedbatchelder.com/text/quicksvnbranch.html. What is the recommended way of doing this without affecting repository’s main structure and the checked out projects on the machines of other developers?
2 Solutions collect form web for “Eclipse project with Subclipse: Introduce trunk and branches”
If you did not establish some structure when you created your repository you cannot do so now without having some impact on existing users. The repository is like a file system. You can create the structure now, but because it will involve moving around where your project is stored it will require users to either checkout from the new location, or use the switch option to update their existing checkout to point at the new location.
How do you do it?
1) Use svn mkdir to create the trunk and branches folder in the repository. You can do this from Subclipse from the SVN Repositories view using the Create Folder option.
2) You then need to move any files and folders that are in the root of your repository to the trunk folder, so that trunk is now the root of your project. I would do this using the command line:
$ svn mv url://host/repos/folder1 url://host/repos/trunk -m "Move folder1 to trunk" $ svn mv url://host/repos/folder2 url://host/repos/trunk -m "Move folder2 to trunk" $ svn mv url://host/repos/file1 url://host/repos/trunk -m "Move file1 to trunk"
When you are done, the root of your repository show now only contain the trunk and branches folders.
3) On your existing checked out project in Eclipse, do Team > Switch. Use the browse button to select the trunk folder in the dialog and click OK. This will update your working copy in place so that it points at the new location.
All users will need to do step 3.
Finally, you are now ready to create branches. Just copy trunk to the branches folder to create a branch. You can do this from Eclipse with Team > Create Branch
Use Team > Switch to switch back and forth between your branches and trunk.
Use Team > Merge to merge changes from trunk to a branch or vice versa.
The Subversive plugin for Eclipse allows you to share your projects to svn as a multiple project layout (
trunk/branches/tags folder structure).
If you’ve already committed your project to svn without the
trunk/branches/tag layout, you’ll have to disconnect your project from svn first by right clicking your project > select Team > Disconnect
You’ll be prompted to delete or keep your SVN meta-information (.svn folder)
Select ‘Also delete the SVN meta-information‘ to share the project with the multiple projects layout. (this will clear your project’s existing svn history, so if you want to keep your original copy with its svn logs, first copy your project with its
.svn folder into a backup folder)
Once your project is disconnected, follow these steps to share it to svn as a multiple projects layout:
- Right click your project
- Select Team > Share Project > SVN
- Select your repository > Advanced Mode > under Project Repository layout, select ‘Use multiple projects layout with the specified root name’ > check Use Subversion recommended layout