266

I have a folder, c:\websites\test, and it contains folders and files that were checked out from a repository that no longer exists. How do I get Subversion to stop tracking that folder and any of the subfolders and files?

I know I could simply delete the .svn folder, but there are a lot of sub-folders in many layers.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Brian Boatright
  • 36,294
  • 34
  • 81
  • 102
  • Refer to my answer which has helped many. http://stackoverflow.com/questions/4889619/command-to-recursively-remove-all-svn-directories-on-windows/12399419#12399419 – Ajit Vaze May 12 '16 at 06:21
  • 1
    If you're using TortioseSVN, I wrote a blog post that shows the fastest way to do this. My post has step-by-step instructions with pictures. That post is available at [http://www.ecofic.com/about/blog/disconnecting-folder-from-svn](http://www.ecofic.com/about/blog/disconnecting-folder-from-svn) – Chad Campbell Jul 27 '13 at 14:07
  • First link is broken. General rule of thumb: Avoid SVN by any means. It's the year 2023 btw. –  Jul 20 '23 at 14:00

29 Answers29

262

Also, if you are using TortoiseSVN, just export to the current working copy location and it will remove the .svn folders and files.

http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-export.html#tsvn-dug-export-unversion

Updated Answer for Subversion 1.7:
In Subversion 1.7 the working copy has been revised extensively. There is only one .svn folder, located in the base of the working copy. If you are using 1.7, then just deleting the .svn folder and its contents is an easy solution (regardless of using TortoiseSVN or command line tools).

crashmstr
  • 28,043
  • 9
  • 61
  • 79
  • 8
    Link is now a 404. New link: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-export.html#tsvn-dug-export-unversion The export-over-current does seem to be just a special case that only removes the .svn files if you say to also keep unversioned files. – lilbyrdie Feb 01 '11 at 20:57
  • after successful removing for getting back your folder icon in normal restart the svn server and that's all – 3ehrang Feb 27 '12 at 08:58
  • The server would not have anything to do with Tortoise folder icons. But if they don't update you can try killing the TSVNCache process. It should restart automatically. – crashmstr Feb 27 '12 at 12:36
  • 1
    In my case, I deleted git folder also together with .svn folder – Aftab Ahmed Kalhoro Jul 23 '18 at 04:36
158

On Linux, this will work:

  find . -iname ".svn" -print0 | xargs -0 rm -r
T.Rob
  • 31,522
  • 9
  • 59
  • 103
Max Cantor
  • 8,229
  • 7
  • 45
  • 59
120

Try svn export.

You should be able to do something like this:

svn export /path/to/old/working/copy /path/to/plain/code

And then just delete the old working copy.

TortoiseSVN also has an export feature, which behaves the same way.

pkaeding
  • 36,513
  • 30
  • 103
  • 141
  • 5
    Thanks for providing an answer that works with the command line. :) Great for those of us using terminals. – epochwolf Aug 10 '09 at 00:01
  • 18
    If I understand correctly, this command will only export the files currently under subversion control. So if some files or folders have not yet been added certain to subversion or were removed from subversion control, you will lose these files in your export... – Chris Jul 26 '10 at 11:01
  • @Chris, yes, you are correct. This will only export the versioned files. This is good for exporting the code, and leaving behind derived artifacts, etc, but it might not be the right tool for every job. – pkaeding Apr 21 '11 at 02:44
  • 5
    Worth a comment that this DOES still work if the SVN server is long gone; if you try to export using VisualSVN or Tortoise SVN it appeares to try to contact the server, but the command line version above worked for me without the SVN server still running. – Dave Feb 16 '12 at 23:38
  • I get an error: `svn: E000002: Can't stat '/.classpath': No such file or directory` – IgorGanapolsky Aug 10 '16 at 19:05
35

If you are running Windows then you can do a search on that folder for .svn and that will list them all. Pressing Ctrl + A will select all of them and pressing delete will remove all the 'pesky' Subversion stuff.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
graham.reeds
  • 16,230
  • 17
  • 74
  • 137
25

On Linux the command is:

svn delete --keep-local file_name
apaderno
  • 28,547
  • 16
  • 75
  • 90
bunteKnete
  • 251
  • 3
  • 3
22

I found that you don't even need to copy to a temporary location. You can do a

svn export --force .

and the .svn files will be removed in situ, leaving the other files as is. Very convenient and less prone to clutter.

I. J. Kennedy
  • 24,725
  • 16
  • 62
  • 87
  • 4
    I don't know what it is, but it did not work for me for some reason. – Aries Jun 22 '11 at 17:09
  • 1
    This command only works for the working copy, not a folder inside it. Maybe a variant of the same... ? –  Jun 29 '11 at 13:39
  • 2
    This will not work if the installed version of Subversion is 1.7 and the repository is for 1.6. However, "svn upgrade" can be run prior to the export and it will work. – Peter Mortensen May 13 '13 at 09:17
11

Without subshells in Linux to delete .svn folders:

find . -name .svn -exec rm -r -f {} +

rm = remove
-r = recursive (folders)
-f = force, avoids a lot of "a your sure you want to delete file XY".
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user1439712
  • 129
  • 2
  • 5
10

None of these answers was satisfactory for my situation. I'm on subversion 1.8 and I had a working copy that only had a single .svn folder at the very first folder, root. However, I wanted to remove some branches from working copy.

No matter what I did, whenever I ran an 'update' it would restore those files and bring them all back. I didn't want to remove them from the repository, just from my computer -- but I needed to keep the rest of the working copy in tact (thus couldn't just remove the .svn folder).

Solution? svn update --set-depth exclude <dir>

This is a client-side "update" that excludes a specific directory. It can be found in the manuals at svnbook.com. In short, it describes this as:

Beginning with Subversion 1.6, you can take a different approach. First, check out the directory in full. Then run svn update --set-depth exclude on the one subdirectory you don't care about.

For TortoiseSVN, you can also do the same thing by right-clicking the folder you don't want, click on Update to revision..., and then set the 'Update Depth' to Exclude, as seen in this screen shot:

enter image description here

brazilianldsjaguar
  • 1,409
  • 1
  • 20
  • 45
8

It worked well for me:

find directory_to_delete/ -type d -name '*.svn' | xargs rm -rf
IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
Manikandan S
  • 902
  • 1
  • 8
  • 18
7

Use the svn export command:

cd c:\websites\test
svn export c:\websites\test_copy

All files under version control will be exported. Double check to make sure you haven't missed anything.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1800 INFORMATION
  • 131,367
  • 29
  • 160
  • 239
5

Just remove the .svn folder inside the required folder then the control will be automatically removed.

Ramudu
  • 51
  • 1
  • 1
4

On Windows, you can add a quicklink for that to your explorer right click menu. Just start this registry script:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_CLASSES_ROOT\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

This will add an item called "Delete SVN Folders" to your right click menu. This will delete all .svn folders in this folder and all subfolders.

Source (German): http://www.sjmp.de/software/alle-svn-ordner-und-dateien-loeschen/

Tobias
  • 7,238
  • 10
  • 46
  • 77
2

You can use "svn export" for creating a copy of that folder without svn data, or you can add that folder to ignore list

andy.gurin
  • 3,884
  • 1
  • 21
  • 14
2

For those using NetBeans with SVN, there is an option 'Subversion > Export'.

Ladik
  • 477
  • 5
  • 8
2

There's also a nice little open source tool called SVN Cleaner which adds three options to the Windows Explorer Context Menu:

  • Remove All .svn
  • Remove All But Root .svn
  • Remove Local Repo Files
Martin Buberl
  • 45,844
  • 25
  • 100
  • 144
  • Release in 2009. I would be precautious using this tool and double checking native SVN client first. –  Jul 20 '23 at 14:01
2

On Windows 7 one can just open the project folder and do a search for ".svn" if hidden files are enabled and delete all found .svn folders.

Unknown_Guy
  • 948
  • 9
  • 17
  • 1
    Win Win XP that works great as well. Note that with SVN 1.7 the `.svn` directories no longer exist scattered around. For more details check out http://subversion.apache.org/docs/release-notes/1.7.html#wc-ng – Joao Coelho Jan 06 '12 at 19:18
1

Another (simpler) Linux solution:

rm -r `find /path/to/foo -name .svn`
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dougvj
  • 6,409
  • 2
  • 23
  • 18
1

The answer is surprisingly simple - export the folder to itself! TortoiseSVN detects this special case and asks if you want to make the working copy unversioned. If you answer yes the control directories will be removed and you will have a plain, unversioned directory tree.

Srikanth
  • 11
  • 1
1

THE BEST AND EASIEST WAY

If you think that you could win with a simple magic command you are failed! SVN is really tricky and always come back somehow with a new error message in Xcode. Sooner or later, promise... so you have to do it smart!

As you know the regular and best practice under Xcode is deleting a file on the project pane on the left. If you missed it and somehow deleted it in Finder you are in trouble. Big trouble! But you could solve it and spare time if you do it well.

First, you need to delete the SVN reference to the file or folder before you could delete it actually

  1. If you could just put back the file/folder from the trash or undo the last step when you deleted it, then...

  2. Go to Terminal - yes, the good old terminal - and go to that location. Best way just type cd then pull the folder/file to the Terminal. You will get something similar

cd /Users/UserName/Documents/Apps_Developing/...

You could check where are you with

ls

command which list your files.

  1. Then you need to delete the svn reference with an SVN command:

    svn delete --keep-local fileName_toDelete

This will delete the file from the SVN repository, BUT you have to delete it manually in Finder.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
BootMaker
  • 1,639
  • 1
  • 22
  • 24
0

My idea is to remove the .svn folder and then move all other files to a new folder. It is as simple as that.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alvin567
  • 305
  • 2
  • 8
0

I use rsync:

# copy folder src to srcStripped excluding subfolders named '.svn'. retain dates, verbose output
rsync -av --exclude .svn src srcStripped
yeeking
  • 958
  • 8
  • 11
0

When you are using the Windows OS, go to your folder location and check hidden files are open, and then you can see the SVN folder in there. Just remove that folder.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dush88c
  • 1,918
  • 1
  • 27
  • 34
0

svn export works fine, but I think this is:

svn rm --keep-local <folder/file>

It removes it from your local repository.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Javier Salinas
  • 617
  • 6
  • 15
0

As a vital point, when you use the shell to delete .svn folders, you need the -depth argument to prevent the find command entering the directory that was just deleted and showing error messages like e.g.

"find: ./.svn: No such file or directory"

As a result, you can use the find command like below:

cd [dir_to_delete_svn_folders]
find . -depth -name .svn -exec rm -fr {} \;
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
fatihk
  • 7,789
  • 1
  • 26
  • 48
0

From a Windows command line:

rmdir .svn /s /q
Michael Ross
  • 572
  • 4
  • 7
0

Use the following:

svn rm --keep-local <folder name> to remove the folder and everything within it.

svn rm --keep-local <folder name>/* to keep the folder, but remove everything within the folder.

Here is an example of what happens:

~/code/web/sites/testapp $ svn rm --keep-local includes/data/*
D         includes/data/json
D         includes/data/json/index.html
D         includes/data/json/oembed
D         includes/data/json/oembed/1.0
D         includes/data/json/oembed/1.0/embed1.json
D         includes/data/json/oembed/1.0/embed2.json
D         includes/data/json/oembed/1.0/embed3.json
Ryan
  • 3,475
  • 2
  • 16
  • 12
0

NetBeans IDE users can do it as below:

  1. Open the SVN project in your IDE
  2. Select the project

    right click Subversion Export

  3. In the dialog box

    export to folder /var/tmp/projectname press export wait will show complete will ask do you want to open it do open on the fly

  4. You can now switch to Git :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
-1

On Windows 10, we need to go to Windows Explorer, and then go to View and check the checkbox for View hidden files.

Then navigate to the folder that has the SVN linked on Windows Explorer and delete the .svn folder/file.

CodeMouse92
  • 6,840
  • 14
  • 73
  • 130
  • Although I edited the formatting, this answer doesn't actually answer the question. The user already knows how to delete the base `.svn` folder, but he is asking about all of the sub-folders. Please **read the question thoroughly.** – CodeMouse92 Apr 27 '16 at 22:02