220

How can I "delete" a file which is already in the SVN repository without deleting it from my file system?

TortoiseSVN or command line instructions are welcome.

The following works, but I am hoping for something nicer:

  1. Copy the file to some other location outside the repository.
  2. SVN Delete the file.
  3. Commit
  4. Copy the files back and make sure to ignore them on future commits.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
srmark
  • 7,942
  • 13
  • 63
  • 74

5 Answers5

269
svn delete --keep-local the_file
phihag
  • 278,196
  • 72
  • 453
  • 469
  • 4
    I am getting a "svn: invalid option: --keep-local" - Is it because I am on 1.4.6? – barfoon May 11 '09 at 17:39
  • 7
    @barfoon: Yes, --keep-local is only available in svn 1.5.0+. I'm afraid you have to manually copy the file beforehand or check it out using svn cat afterwards. – phihag May 12 '09 at 08:51
  • 4
    And remember to do a commit after this operation. – Teemu Leisti Feb 23 '12 at 13:08
  • 1
    Does anyone know if this procedure will delete the file from other users when they update? – BrDaHa Jul 24 '14 at 22:54
  • 4
    WHen users update, they get the newest version from the repository. Since the question asks how to delete a file from the repository, other users will find the_file removed when they update. – phihag Jul 25 '14 at 04:44
  • 4
    Thats what I was trying to avoid. It's so hard to just erase something from SVN once something's accidentally been checked in... – BrDaHa Jul 25 '14 at 17:21
108

Deleting files and folders

If you want to delete an item from the repository, but keep it locally as an unversioned file/folder, use Extended Context Menu → Delete (keep local). You have to hold the Shift key while right clicking on the item in the explorer list pane (right pane) in order to see this in the extended context menu.

Delete completely:
right mouse click → Menu → Delete

Delete & Keep local:
Shift + right mouse click → Menu → Delete

Community
  • 1
  • 1
crashmstr
  • 28,043
  • 9
  • 61
  • 79
65

In TortoiseSVN, you can also Shift + right-click to get a menu that includes "Delete (keep local)".

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
harpo
  • 41,820
  • 13
  • 96
  • 131
1

Rename your file, commit the changes including the "deleted" file, and don't include the new (renamed) file.

Rename your file back.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Avram
  • 4,267
  • 33
  • 40
-2

When you want to remove one xxx.java file from SVN:

  1. Go to workspace path where the file is located.
  2. Delete that file from the folder (xxx.java)
  3. Right click and commit, then a window will open.
  4. Select the file you deleted (xxx.java) from the folder, and again right click and delete.. it will remove the file from SVN.
Timothy Jones
  • 21,495
  • 6
  • 60
  • 90
pavan
  • 33
  • 2
  • 2
    This will delete the file - but isn't the question is about keeping the original file around after it's been removed from SVN? – Timothy Jones Mar 07 '12 at 00:45