How to delete files from SVN

From The DarkMod Wiki
Jump to navigationJump to search

After reading this article you should be able to remove files from the darkmod SVN repositories. It's assuming that you have a working copy of the darkmod SVN repository checked out on your hard drive and you're using TortoiseSVN.

Things to remember:

  • Think twice before removing files that might be referenced by maps, models or textures.
  • Highlight the files, right-click one of them and choose SVN > Delete..., hit OK.
  • Commit your change (right-click the parent folder and choose SVN Commit...)

General

Just deleting a file from a repository won't do anything. During the next Update SVN will think the file is missing on your end and it will get restored. To actually remove a file from the repository, you need to specifically tell SVN to do so.

Background information: deleting a file from SVN just removes it from the HEAD revision, the file is still available in the SVN history. The SVN server never deletes anything.

Also, be sure that you know what you're doing before you start removing stuff from the SVN server. The files (materials, entityDefs, textures, models) might be referenced by other files, and deleting them might break things. Just keep this in mind.

Mark the files for Deletion

Let's assume we want to remove an old material file from the repository, in this example I'm going to remove the file unknown.mtr.backup from the materials/ folder (actually, I'm pretending to do so, just play along):

Svn delete 1.jpg

The file will disappear from the file viewer. Note that the deletion is not yet completed, you have to commit your changes.

Note about folders: in case you marked an entire folder for deletion, the folder won't just disappear from Explorer like files. Instead, the deleted folders will be tagged with a red X icon, indicating that they will be removed the next time you commit.

Commit the Deletion

Now, right-click on the new file's parent folder (in our example the material/ folder) and choose SVN Commit..., you'll see something like this:

Svn delete 2.jpg

Note the remark "deleted" in the list of affected files - it's also displayed in red. Enter a log message (mandatory) describing the reason of your deletion. As soon as you click OK, the change will be committed and the file is removed from the HEAD revision.

Note: As soon as other people will Update their working copy, the deletion will be propagated to their hard drives. You might want to give the rest of the team a heads-up about the deletion, in case they have local modifications of the deleted file they want to keep.

Accidentally removed files

In case you marked the wrong file to version control, you can undo that operation (before you commit) by choosing SVN > Revert. Right-click the parent folder, choose revert and be sure that the check mark next to the accidentally deleted file is active. Hitting OK will remove the deletion mark and make the file reappear.

In case you already committed the wrong file, you'll have to retrieve the file from the SVN History. Use TortoiseSVN's repository browser and go to the location where you deleted the file. Then, type in the revision number in the upper right entry box and hit Enter. Choose a revision where the file has still existed (think of that like of a time machine). Then you can save that file to your hard drive and re-add it like described in the How to add files to SVN article. Or ask in the forums how to do it, it's not very hard.