DevOps Zone is brought to you in partnership with:

Jessica Thornsby is the Technical and Creative Copywriter at WANdisco, where she writers regular tutorials on Apache Subversion, TortoiseSVN, uberSVN, and all things version control. She spends her spare time editing the CD reviews section at www.leedsmusicscene.net, contributing to A Short Fanzine About Rocking, and researching her family tree. You can find her on Twitter @jthornsby Jessica is a DZone MVB and is not an employee of DZone and has posted 29 posts at DZone. You can read more from them at their website. View Full User Profile

Adding and Deleting Files from Command Line

02.25.2013
| 2845 views |
  • submit to reddit

When working with files under Apache Subversion’s version control, eventually you will need to start adding and removing files from your project. This week’s tip explains how to add a file to a project at the working copy level or, alternatively, commit it straight to the central repository. It will also highlight how to delete a file, either by scheduling it for deletion via the working copy or deleting it straight from the central repository.

Adding Files

Files can be added to a project via the working copy. After you’ve added the file to your working copy, it’ll be sent to the central repository and shared with the rest of your team the next time you perform an ‘svn commit.’

To add a file to your working copy (and schedule it for addition the next time you perform a commit) run:

svn add (working-copy-location)/file-to-be-added

In this example we’re adding a file called ‘executable’ to the trunk directory of the ‘NewRepo’ working copy.

Subversion 1

You’ll need to perform a commit to send this item to the repository and share it with the rest of your team.

Subversion 2

Deleting Files 

Once you start adding files to your working copy, sooner or later you’ll need to remove files. When files are deleted in the working copy, they’re scheduled for deletion in the repository the next time you perform a commit, in exactly the same way as the ‘svn add’ command.

Schedule files for deletion in the working copy by running:

svn delete (working-copy-location)/file-to-be-deleted

In this example, we’re scheduling ‘executable.png’ for deletion.

Subversion 3

Alternatively, you can delete files from the repository immediately. Note, this operation creates a new revision and therefore requires a log message.

svn delete -m “log message” (repository-URL)/file-to-be-deleted

Subversion 4

Published at DZone with permission of Jessica Thornsby, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)