• Home
  • Subversion Hosting
  • Documents
  • Contact Us
  • Members Login

Deleting, Renaming And Moving

Unlike CVS, Subversion allows renaming and moving of files and folders. So there are menu entries for delete and rename in the TortoiseSVN submenu.

Figure 5.25. Explorer context menu for versioned files

Explorer context menu for versioned files

If you delete a file/directory using TSVN, the file is removed from your working copy and marked for deletion. The file's parent folder shows a "deleted" icon overlay. You can always get the file back, if you call TortoiseSVNRevert on the parent folder.

If you want to move files inside a working copy, use the drag-and-drop handler again:

  1. select the files or directories you want to move

  2. right-drag them to the new location inside the working copy

  3. release the right mouse button

  4. in the popup menu select Context MenuSVN Move versioned files here

Do Not SVN Move Externals

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, probably upsetting many other people. If you need to move an externals folder you should use an ordinary shell move, then adjust the svn:externals properties of the source and destination parent folders.

If a file is deleted via the explorer instead of using the TortoiseSVN context menu, the commit dialog shows those files and lets you remove them from version control too before the commit. However, if you update your working copy, Subversion will spot the missing file and replace it with the latest version from the repository. If you need to delete a version-controlled file, always use TortoiseSVNDelete so that Subversion doesn't have to guess what you really want to do.

If a folder is deleted via the explorer instead of using the TortoiseSVN context menu, 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 TortoiseSVNDelete.

Commit the parent folder

Since renames and moves are done as a delete followed by an add you must commit the parent folder of the renamed/moved file so that the deleted part of the rename/move will show up in the commit dialog. If you don't commit the removed part of the rename/move, it will stay behind in the repository and an update of your coworkers won't remove the old file. i.e. they will have both the old and the new copies.

You must commit a folder rename before changing any of the files inside the folder, otherwise your working copy can get really messed up.

Getting a deleted file or folder back

If you have deleted a file or a folder and already committed that delete operation to the repository, then a normal TortoiseSVNRevert can't bring it back anymore. But the file or folder is not lost at all. If you know the revision the file or folder got deleted (if you don't, use the log dialog to find out) open the repository browser and switch to that revision. Then select the file or folder you deleted, right-click and select Context MenuCopy to... as the target for that copy operation select the path to your working copy.

Renaming a file only in case

In case you have two files in the repository with the same name but differing only in case (e.g. TEST.TXT and test.txt) you can't update or checkout the directory where those files are in anymore.

In that case, you have to decide which one of them you want to keep and delete (or rename) the other one from the repository.

There are (at least) two possible solutions to rename a file without losing its log history. It is important to rename it within subversion. Just renaming in the explorer will corrupt your working copy!!!

Solution A) (recommended)

  1. Commit the changes in your working copy.

  2. Rename the file from UPPERcase to upperCASE directly in the repository using the repository browser.

  3. Update your working copy.

Solution B)

  1. Rename from UPPERcase to UPPERcase_ with the rename command in the TortoiseSVN submenu.

  2. Commit the changes.

  3. Rename from UPPERcase_ to upperCASE.

  4. Commit the changes.

Preventing two files with the same name

There is a server hook script available at: http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ that will prevent checkins which result in case conflicts.

All Plans Include

All plans free for 2008
Trac wiki linked to each repository
Online management tools
Access control lists (ALCs)
Read only or read write users
Secure HTTPS connections
Data mirrored onto backup servers
Disk usage reporting
Online invoices & payments
Unlimited support
Click for Free Subversion Hosting