How to install Subversion (SVN) with Eclipse on Windows
Subversion looks to be the new version control system of choice in the open source community, supplanting CVS which supplanted RCS. This article, Why Subversion Over CVS, gives some reasons to choose Subversion over CVS. Many people also choose subversion over commercial products such as ClearCase and Visual Source Safe. The authors of "Windows Developer Power Tools" (O'Reilly 2006) write:
Subversion is our favorite version-control system, and we definitely recommend it above all others (including commercial products) in most scenarios. There may be certain areas where commercial systems excel, but for overall version control, it's tough to beat Subversion.
Step by step instructions
Here are my notes for installing Subversion, TortoiseSVN (a Subversion client which integrates with Windows Explorer), and Subclipse (the plugin for Eclipse integration) on Windows. This assumes you already have Eclipse installed. Also, these notes are geared towards version control for individual use as opposed to team use.
- Install Subversion and TortoiseSVN using SVN 1-Click Setup
- Go to http://svn1clicksetup.tigris.org/, click "Download the latest version", run the installer, and accept all the defaults.
- This is a Windows installer used "to simplify the process of setting up a Subversion repository on a Windows-based computer. Svn1ClickSetup takes a user through the steps necessary to install the Subversion command-line utilities and TortoiseSVN, as well as creating a repository and initial project." --from svn1clicksetup.tigris.org
- To check that something went right, go to Windows Explorer and right-click on a file. You should see the "TortoiseSVN" context menu item.
- Install the Subclipse plugin using the instructions at http://subclipse.tigris.org/install.html.
- Define the SVN Repository
- In Eclipse, from the "Window" menu, select "Open Perspective" > "Other...". Select "SVN Repository Exploring" and click "OK".
- Inside the "SVN Repository" window, right-click in the big empty space, and select "New" > "Repository Location...".
- In the "Url:" box, type "svn://localhost". Click "Finish". (Use this url to connect to the repository hosted on the SVN server on your local machine created using svn1clicksetup. I got this tip from http://james.cooley.ie/2006/12/01/version_control_with_eclipse_on_windows.html. If you want to use a repository on another server, then point to that location instead. "file://, http://, or https:// are the other protocols that can be used.)
- Add an Eclipse project to the repository
- In the "Navigator" window, right-click on a project and select "Team" > "Share Project...".
- Select "SVN" and click "Next"
- Your repository, "svn://localhost", (which you added in step 3) should show up here. Click "Next".
- Click "Next" again. Click "Finish". I got the following output in the "Console" window:
Filesystem has no item svn: URL 'svn://localhost/my_project' non-existent in that revision mkdir -m "Initial import." svn://localhost/my_project checkout -N -r HEAD svn://localhost/my_project Checked out revision 5.
- Select the files you want to add and click "OK". I got the following output in the "Console" window:
add -N C:\path\to\my_project\test.py A C:/path/to/my_project/test.py commit -m "Initial import." C:/path/to/my_project/test.py Adding path/to/my_project/test.py Transmitting file data ... Committed revision 6.
- See this article for more information: How to use Subversion with Eclipse
- Modify and commit a file
- Edit one of the newly added files and save it.
- In the "Navigator" window, right-click on the file, and select "Team" > "Commit...".
- Enter a comment and click "OK". I got the following output in the "Console" window:
commit -m "test" C:/path/to/my_project/test.py Sending path/to/my_project/test.py Transmitting file data ... Committed revision 7.
- Show the history for a file
- In the "Navigator" window, right-click on the file, and select "Team" > "Show History".
- The "History" window should open showing the revisions of your file. Double-click on a revision to open it or right-click for other options.