Computer Laboratory

Deleting/Renaming files and directories

This information is from TortoiseSVN Help

Subversion allows the renaming and moving of files and folders, which can be done from the TortoiseSVN submenu (see image below):

deleting files menu

Below lists the general instructions on how to delete or move files. It is advised, however, that you consult the TortoiseSVN Help for precise information on deleting files.

Note:
  • Recovering deleted files requires a measure of understanding about Subversion and how it works.
  • Whilst the Repository holds information about all previous versions of files, it is time consuming to retrieve a file, should things go wrong.
  • Be sure you know what you are doing before you enter into file deletion.
  • If in any doubt, please ask a pagemaster to help you, rather than risk corrupting your working copy.

Deleting files

Where possible, always use TortoiseSVN -> Delete to delete files, so Subversion doesn't have to guess what you really want to do.
The following describes the numerous ways of deleting files, (and the muddle you can get in if you don't use TortoiseSVN -> Delete!)

  • Marked for deletion:

    If you delete a file/directory using TortoiseSVN, the file is removed from your working copy and marked for deletion with the red cross icon icon.

  • Retrieving a file:

    You can always get the file back using TortoiseSVN -> Revert on the parent folder.

  • Moving files:

    If you want to move files inside a working copy, use the drag-and-drop handler:
    • Select the files or directories you want to move.
    • Right-drag the files to the new location inside the working copy.
    • Release the right mouse button.
    • In the popup menu, select Context Menu-> SVN Move versioned files here.
    .

  • You should not use the TortoiseSVN Move or Rename commands on a folder which has been created using svn:externals.
    This action would cause the external item to be deleted from its parent repository.
    If in doubt, seek advise from a pagemaster

    .
  • Ooops, I deleted via explorer not TortoiseSVN

    If a file is deleted via the explorer instead of using the TortoiseSVN Context Menu, the commit dialogue box will display these files and and allow you to remove them from version control before the commit.
    If a folder is deleted in this way, your working copy will be broken and you will be unable to commit.
    If you update your working copy, Subversion will replace the missing folder with the latest version from the repository and you can then delete it the correct way using TortoiseSVN -> Delete.
  • Ooops I updated the file without using TortoiseSVN Delete:

    If the working copy is updated, Subversion will find the missing file and replace it with the latest version from the repository.
    Where possible, always use TortoiseSVN -> Delete to delete files, so Subversion doesn't have to guess what you really want to do.

Advanced notes

  • Commiting a parent folder:

    You must commit a folder rename before changing any of the files inside the folder, otherwise your working copy will become filled with old and new copies of the same file.
    This is because Subversion runs a delete command followed by an add command.
    If you don't commit the changed parent folder to show a deletion, it will stay behind and the new version will be added to it.
    This will mean that other authors won't know which is the correct version.

  • Getting a deleted file or folder back

    If you have not committed a delete operation to the repository, then use TortoiseSVN -> Revert to retrieve the file.
    If you have already committed the deletion:
    • Use the log dialogue box to find out the revision of your file
    • Open the repository browser and switch to that revision
    • Right-click the file or folder you deleted and select Context Menu > Copy to... as the target for that copy operation
    • Select the path to your working copy.