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.
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.
You’ll need to perform a commit to send this item to the repository and share it with the rest of your team.
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.
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