Get to know Subversion as a replacement for CVS
Takeaway: Vincent Danen shows you some of the common commands for using Subversion and gives you an example of setting up a Subversion repository.
Subversion is a version control system similar to CVS, but different in a number of respects that make it more robust and quite a bit better. Subversion is quickly becoming an extremely popular replacement for CVS. (In a previous tip, I showed you how to connect to a subversion repository using an Apache 2 Web Server.)
A lot of the commands are similar to what CVS provides, but they can be different in a few ways. The svn command is the equivalent to the cvs command; and svnadmin is the equivalent to the cvs admin command.
To create a subversion repository, use:
<code>
$ svnadmin create ~/subversion/repos
</code>
This would create a repository in your home directory in ~/subversion/repos. To add a directory to the repository, use:
<code>
$ svn mkdir file:///home/user/subversion/repos/www
</code>
This would add the directory www to your repository. To add a newly created file to the repository in the www directory, use:
<code>
$ cd ~/subversion/repos/www
$ svn add index.php
$ svn commit
</code>
Then, if you were to make changes to index.php after it was committed, you could view a diff of the changes you made and then commit those changes:
<code>
$ svn diff index.php
$ svn commit
</code>
Note that svn looks for the EDITOR or SVN_EDITOR environment variables to set the name of the text editor to use when writing commit messages, but you can also specify the commit log message on the command line using:
<code>
$ svn commit --message "Changed the copyright"
</code>
To checkout a working copy of something in the repository, you would use:
<code>
$ svn checkout http://yourserver/svn/www
</code>
or:
<code>
$ svn checkout file:///home/user/subversion/repos/www
</code>
You would use the former snippet if you have subversion setup through Apache to access your repositories, and the latter is if you're just using a local repository.
To view those commit (log) messages for a particular file, use:
<code>
$ svn log index.php
</code>
These are pretty much the basics to using subversion, from a client perspective. In a number of ways, the svn client is very similar to the cvs client; this was done intentionally to make the migration from cvs to svn a lot less painful and make subversion feel a little more familiar to new users.
SponsoredWhite Papers, Webcasts, and Downloads
- The Economist: A new mandate for IT SAP
- Seeing the Big Picture: A Corporate Guide to Better Decisions through IT SAP
- Still Struggling to Reduce Call Center Costs Without Losing Customers? The Right Technologies Lead the Way Out of the Call Center Dilemma SAP
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET

