ChatGPT解决这个技术问题 Extra ChatGPT

Remove file from SVN repository without deleting local copy

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:

Copy the file to some other location outside the repository. SVN Delete the file. Commit Copy the files back and make sure to ignore them on future commits.


p
phihag
svn delete --keep-local the_file

I am getting a "svn: invalid option: --keep-local" - Is it because I am on 1.4.6?
@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.
And remember to do a commit after this operation.
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.
Thats what I was trying to avoid. It's so hard to just erase something from SVN once something's accidentally been checked in...
C
Community

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


P
Peter Mortensen

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


P
Peter Mortensen

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

Rename your file back.


T
Timothy Jones

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

Go to workspace path where the file is located. Delete that file from the folder (xxx.java) Right click and commit, then a window will open. Select the file you deleted (xxx.java) from the folder, and again right click and delete.. it will remove the file from SVN.


This will delete the file - but isn't the question is about keeping the original file around after it's been removed from SVN?