Saturday, August 24, 2013

How to delete versioned SVN files from repository without deleting locally in TortoiseSVN

TortoiseSVN


If you are a developer working on a Windows operation system and using SVN for your version control, chances are that you are using TortoiseSVN so that you don't have to manually input SVN commands. Instead, you can just use the context menu items to click whatever command that you want to execute.



I will be particularly be talking about the delete command in this article.



Don't delete my local files!


There is one use case that really annoyed me about deletion in SVN. 

That is when I am trying to remove SVN files from the repository but somehow retain it in my local copy.

The delete in the context menu deletes both the files from the repository and the local copy.

To circumvent this problem, here are the steps that I did
  1. Copy the files and folders that I want to retain to a temporary folder. 
  2. Delete the files using the SVN context menu. This will delete the local copy too.
  3. Move the files back to where I copied them from
This solution is tedious and error-prone. What If I copied the .svn files? What if I forget to copy an obscure yet essential file? Surely, the whole purpose of version control is avoid these problems entirely!

I grudgingly used this workflow before because I didn't have the time to come up with an elegant solution to the problem. It is only recently that I finally decided to find a better solution. I didn't believe that SVN doesn't have a feature for this exact use case since I think this is a common enough to warrant this feature.

Sure enough, SVN does have it.

The Solution


To do it via the command line, you can simply type this
svn delete filename --keep-local

However, TortoiseSVN users will probably prefer a "point-and-click" solution to do this. Fortunately, there is a way!

The way to do it is
  1. Select the file(s) that you want to delete
  2. Hold the Shift button
  3. Right click on the file(s) that you want to delete
If you go to the SVN context menu, you will now see that there is a new command called Delete(keep local)



This is the command that we want to run.

Hope this helps!






0 comments:

Post a Comment

Programming and Computer Science

Powered by Blogger.