Subclipse for SVN on Eclipse CDT

Subversion is a great way to work on code in a collaborative fashion. There are a couple subversion plugins that work with Eclipse, one of them is called Subclipse.

To install Subclipse in Eclipse goto the Help menu and choose "Software Updates...".

Once the "Software Updates and Add-ons" window displays itself we need to add the Subclipse update URL. Choose the "Available Software" tab, click "Add Site" and put in "http://subclipse.tigris.org/update_1.6.x" as the location and click "OK".

Add Plugin Location

You will now see a new item in the list corresponding to the URL that you just added. Now to add subclipse you need to choose two plugins, subclipse itself and the JavaHL. JavaHL is the API that subclipse uses to talk to your SVN server. You can find these by expanding the tree by clicking the triangle to the left of the URL you just added, and then expanding the Subclipse subnode. After selecting the plugins click install and follow the dialogs through to the end.

Plugin Selection

Now that subclipse is installed, in the top right of Eclipse click the "Open Perspective" icon choose "Other" and choose "SVN Repository Exploring", this perspective will give you the tools to work with your SVN repo, assuming you aren't already happily using a tool like TortoiseSVN or the command line client to do so.

Add your repo location to the SVN perspecitve by clicking the icon at the top right of the repositories view and typing in the URL of your repo. Any repositories added here will also show up in other dialogs when working with SVN in Eclipse such as when adding or importing projects.

Add Repository

Adding Your Project to the SVN Repository

To add a project to SVN go back to your development perspective and simply right click on the project in the "Project Explorer", expand the "Team" subitem and choose "Share Project...". Now choose what repository to add your project to, click Next.

Choose Repository

Now you will be prompted to choose a folder name for your project in the repo; you can just use the name of the project or specify some folder further down in your repository hierarchy, click Next.

Repository Folder

The wizard will now ask for an initial commit comment, click Finish and your project will be created in the repo, but you will still need to commit your changes for the code to actually show up in SVN.

Ready to Share

Once you clicked Finish Eclipse will ask if you want to open the "Team Synchronizing" perspective. Click yes and once the perspective opens you can simply right click on the root project node and choose commit. You can also do commits from the SVN perspective, or in your development perspective the project right-click menu now has a bunch of SCM options under the Team submenu.

Team SCM Operations

At this point working with SVN in Eclipse is like working with any SCM tool, make changes, commit changes, rinse, repeat.

Importing a Project from SVN

There may be a project in an SVN repo that you want to import, this is fairly simple. Open the workspace that you want to import the project into. Goto "File" and choose "Import". Expand SVN in the tree and choose "Checkout Project from SVN", click Next.

Import from SVN

This next dialog lets you choose from which SVN location to pull the project, if you have already added a repo location in the SVN repo perspective it will show on the dialog, otherwise you can specify the location now, click Next. You will now be shown a list of folders on your repository, you can navigate them and click the folder that you'd like to import, click Next.

Choose Project Folder

The next window asks how you would like to setup the local project, including a name and which version to pull. The defaults should usually suffice unless you want to maybe pull and older version or a branch to work on, click Next.

Local Project Properties

The next dialog simply lets you import to a different workspace than the one you currently have mounted. You should already be in the workspace you want to import to so just click finish. The import process will take a moment after which you should see a new project in your workspace.

Congratulations, you've successfully imported the project and since it is bound to SVN you can now work on the code with your coworkers!