How to setup a subclipse project to branch/tag
I've read that branching/tagging is one of the nice features of SVN (See Mark Phippard's blog and the subversion book). However, it took me a little while to figure out how to set up my directory structure with the recommended "trunk", "branches", and "tags" folders. These are my basic step-by-step notes for how I set up my Subclipse project and then created a branch. This assumes you've already installed Subclipse and set up a repository. If you have not done that, see How to install Subversion (SVN) with Eclipse on Windows.
- Add your Eclipse project to the repository in a "trunk" folder
- Start with an Eclipse project named "myproject"
- In the "Navigator" window, right-click on your project, select "Team" > "Share Project..."
- Select "SVN" and click "Next"
- Select your repository. (This tutorial assumes it is located at "svn://localhost".) Click "Next".
- In the "Enter Folder Name" dialog, select the "Use specified folder name" option and enter "myproject/trunk". The "URL:" box should show something like "svn://localhost/myproject/trunk". Click "Next".
- Click "Finish". A new dialog will open. Select the
files to commit, enter a comment, and click "OK". I got the
following output in the "Console" window:
Filesystem has no item svn: URL 'svn://localhost/myproject/trunk' non-existent in that revision Bad URL passed to RA layer svn: URL 'svn://localhost/myproject' non-existent in revision '234' mkdir -m "Initial import." svn://localhost/myproject mkdir -m "Initial import." svn://localhost/myproject/trunk checkout -N -r HEAD svn://localhost/myproject/trunk Checked out revision 236. add -N C:\path\to\myproject\.settings A C:/path/to/myproject/.settings add -N C:\path\to\myproject\.settings\org.eclipse.cdt.core.prefs A C:/path/to/myproject/.settings/org.eclipse.cdt.core.prefs add -N C:\path\to\myproject\.cdtbuild A C:/path/to/myproject/.cdtbuild add -N C:\path\to\myproject\.settings\org.eclipse.cdt.managedbuilder.core.prefs A C:/path/to/myproject/.settings/org.eclipse.cdt.managedbuilder.core.prefs add -N C:\path\to\myproject\.cdtproject A C:/path/to/myproject/.cdtproject add -N C:\path\to\myproject\.project A C:/path/to/myproject/.project commit -m "Initial import." C:/path/to/myproject/.cdtbuild C:/path/to/myproject/.cdtproject C:/path/to/myproject/.project C:/path/to/myproject/.settings C:/path/to/myproject/.settings/org.eclipse.cdt.core.prefs C:/path/to/myproject/.settings/org.eclipse.cdt.managedbuilder.core.prefs Adding path/to/myproject/.cdtbuild Adding path/to/myproject/.cdtproject Adding path/to/myproject/.project Adding path/to/myproject/.settings Adding path/to/myproject/.settings/org.eclipse.cdt.core.prefs Adding path/to/myproject/.settings/org.eclipse.cdt.managedbuilder.core.prefs Transmitting file data ... Committed revision 237.
- Create "branches" and "tags" folders in the repository
- Switch to the "SVN Repository Exploring" perspective. (From the "Window" menu, select "Open Perspective" > "Other...". Select "SVN Repository Exploring" and click "OK".)
- In the "SVN Repository" window, expand the tree, and right-click on "myproject", select "New" > "New remote folder".
- In the "Create a new remote folder" dialog, expand the tree and select "myproject". For "Folder name:", enter "branches". Click "Next".
- Enter a comment and click "Finish".
- Expanding the "myproject" folder now shows the "branches" and "trunk" subfolders.
- I got the following output in the "Console" window:
mkdir -m "Created branches folder." svn://localhost/myproject/branches
- Repeat these steps to create a "tags" folder.
- Create a branch
- Switch back to the previous perspective.
- Commit any changes you want in the branch.
- In the "Navigator" window, right-click your project and select "Team" > "Update"
- Right-click your project and select "Team" > "Branch/Tag..."
- In the "Copy (Branch/Tag)" dialog, in the "To URL:" textbox, enter "svn://localhost/myproject/branches/mybranch". (The "From WC at URL:" box should read "svn://localhost/myproject/trunk".)
- Leave the "HEAD revision in the repository" option selected, enter a comment, and click "OK".
- I got the following output in the "Console" window:
copy -rHEAD svn://localhost/myproject/trunk svn://localhost/myproject/branches/mybranch
- Switch your working copy to the branch
- You can now switch your working copy between the trunk and the branch.
- Right-click your project and select "Team" > "Switch to another Branch/Tag..."
- In the "To URL:" textbox, enter "svn://localhost/myproject/branches/mybranch". Click "OK".
- I got the following output in the "Console" window:
switch svn://localhost/myproject/branches/mybranch C:/path/to/myproject -rHEAD At revision 239.
- You should now be able use the features discussed in Enhanced Support for Branches and Tags in Subclipse
Branching steps were taken from How to branch with Subclipse.
16
Comments
—
Comments feed for this post
#3 Chandra commented on 2009-08-03:
This short article was really helpful. I was struggling quiet a while to incorporate branches for my project. Thanks again.
#6 Clayton E. Cramer commented on 2010-08-13:
Excellent! Exactly what I needed, and couldn't find elsewhere.
#7 vikas commented on 2010-09-01:
really thanks. Struggled for 3-4 hrs but understand completely now due to this very helpful doc.Thanks again
#8 Tung commented on 2011-03-13:
Tks, very helpful tute on SVN branching in Eclipse, exactly what official eclipse manual is missing.
Anyway you can improve its ranking in Google?
#9 Eliot commented on 2011-03-14:
Tung: Thanks for the link on your blog. That'll help the Google ranking. :)
#11 Henrythemouse commented on 2011-06-12:
A super howto. Thanks for posting this. In my case there was one added step needed as I have multiple repos under one directory and the only access to my repos is with apache webdav (I'm not running the svn deamon).
For example:
parentPath = /svn
repo1 = /svn/dave http://host/svn/dave
repo2 = /svn/sue http://host/svn/sue`
If I select one of the repos to share then the "Enter Folder Name" dialog ends up like this:
http://host/svn/sue/sue
which doesn't exist as a valid repo.
So at that point I created a new repository location using "http://host/parentPath". Then I could add a repo name in that dialog and it will check out that repo. This parentPath repository won't work under eclipse subversion listing, but that's not needed anyway. The files check out fine and svn functions work fine.
Without your howto I would have had a much harder time figuring it all out.
Thanks again.
#14 Deep commented on 2012-11-02:
It was very helpful to me to setup trunk, branch and tag for the first time, Thank you! I found this guide very clear and concise.
Post a comment
About
I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »
Search Blog
Tags
-
algorithms
(6)
-
android
(2)
-
aws
(10)
-
blogproject
(20)
-
c_cplusplus
(12)
-
cardstore
(8)
-
colinux
(2)
-
concurrency
(13)
-
conkeror
(2)
-
core
(2)
-
cygwin
(17)
-
datastructures
(15)
-
datetime
(4)
-
decorators
(4)
-
django
(41)
-
emacs
(22)
-
files_directories
(12)
-
git
(6)
-
hardware
(6)
-
install_setup
(8)
-
javascript
(3)
-
keyboard
(9)
-
matplotlib
(6)
-
mercurial
(4)
-
nginx
(2)
-
persistence
(6)
-
preferences
(7)
-
processes
(4)
-
pyqt
(18)
-
python
(157)
-
ratpoison
(3)
-
regexes
(6)
-
rsync
(3)
-
softwaretools
(17)
-
sql
(14)
-
ssh
(12)
-
subversion
(6)
-
twisted
(7)
-
ubuntu
(66)
-
urxvt
(5)
-
vxworks
(25)
-
webdev
(8)
-
wmii
(7)
Blogroll
- Adam Gomaa
- Alex Clemesha
- Amir Salihefendic
- Armin Ronacher
- David Beazley
- David Ziegler
- Duncan McGreggor
- Gareth Rushgrave
- Glyph Lefkowitz
- Guido van Rossum
- Ian Bicking
- Jacob Kaplan-Moss
- James Bennett
- James Tauber
- Jesper Noehr
- Marty Alchin
- Matt Harrison
- Nikolay Kolev
- Parand Darugar
- Peter Baumgartner
- Peter Bengtsson
- Rob Hudson
- Simon Willison
- Will McGugan
#1 robert commented on 2009-02-10:
Cheers for this. I've been looking for a decent explanation of all this stuff for ages. I've now spent the last 2 hours setting up all my Eclipse projects with SVN, which is something I should have done years ago. Thanks again.