While graphical clients such as TortoiseSVN are ever-popular with Apache Subversion users, it’s useful to have the option of interacting with Subversion from the command line. In the first of our introductory posts, we looked at checking out a working copy and committing your first changes back to the repository. In this follow-up tutorial, we focus on working with files in your local copy, and share some useful commands for getting all the information you need on your files and directories.
Adding Files in Subversion
Performing a checkout will create local copies of all the files in your repository, but at some point you may want to add completely new files or directories to your working copy. Once you have manually created or moved the file to your working copy, you must tell Subversion to include this file in its version control. This can be done by running the ‘svn add’ command and specifying where the new file is located in your working copy:
svn add {location}
For example, if you have just created a new text file called ‘howto’ in the trunk, you would enter the following command:
Hit ‘Enter,’ and the specified file will automatically be added to the repository when you perform your next commit.
Deleting Files in Subversion
If you can add files, then at some point you may need to delete them. To delete a file in your working copy, use the ‘svn delete’ command and specify the location of the file you wish to delete:
svn delete {location}{filename}
For example, if you wanted to remove the How To document we have just added, you would use the following command:
Do not delete files under version control using the Explorer menu, as Subversion will flag these files as ‘missing,’ and you will be unable to commit your changes until the deleted files have been restored.
Getting More Info
Now you know how to add and remove files from your working copy, we will cover the various commands that can be used to gather more information about your files, directories, working copy and repository.
- To view the history of files in either the working copy or the repository, use the ‘svn log’ command, followed by either the repository URL or working copy location:
- It is good practice to review your changes before committing them to the repository. This can be done by running ‘svn status,’ which will print the status of your working copy:
- At certain points during the development process, it may be useful to view a list of the repository, or working copy’s contents. This can be found using the ‘svn list’ command, and specifying either the repository’s URL or the working copy’s location:
svn log {URL}
svn log {location}
For example, if you wanted to examine the history of the working copy, you would run:
If the command is successful, you will see a dialog similar to the one below:
svn status {location}
svn list {URL}
svn {location}
If you wanted to bring up a list of the repository’s contents, the command and dialog will look similar to this:
Getting Help
This post, together with our ‘Into to Command Line Subversion’ have covered the basic workcycle of interacting with Subversion from the command line – but there’s still plenty more to explore! If you need more information on what a particular command means, Subversion has ‘svn help’ which can be run, followed by the command in question:
svn help {command}
For example, if you needed more information on the ‘commit’ command, you would run:
Hit ‘Enter’ to display all the relevant information about the command.
Ready to get started with Subversion? Download free, certified binaries from WANdisco.















0 Responses to “Working with Files from the Subversion Command Line”