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.
This question is related to
svn
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.
On Linux, this will work:
find . -iname ".svn" -print0 | xargs -0 rm -r
It worked well for me:
find directory_to_delete/ -type d -name '*.svn' | xargs rm -rf
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.
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.
My idea is to remove the .svn folder and then move all other files to a new folder. It is as simple as that.
You can use "svn export" for creating a copy of that folder without svn data, or you can add that folder to ignore list
svn export
works fine, but I think this is:
svn rm --keep-local <folder/file>
It removes it from your local repository.
For those using NetBeans with SVN, there is an option 'Subversion > Export'.
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.
I use rsync:
# copy folder src to srcStripped excluding subfolders named '.svn'. retain dates, verbose output
rsync -av --exclude .svn src srcStripped
On Linux the command is:
svn delete --keep-local file_name
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:
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.
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".
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/
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.
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.
Another (simpler) Linux solution:
rm -r `find /path/to/foo -name .svn`
Just remove the .svn folder inside the required folder then the control will be automatically removed.
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 {} \;
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
NetBeans IDE users can do it as below:
Select the project
right click Subversion Export
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
You can now switch to Git :)
There's also a nice little open source tool called SVN Cleaner which adds three options to the Windows Explorer Context Menu:
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.
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
If you could just put back the file/folder from the trash or undo the last step when you deleted it, then...
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.
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.
From a Windows command line:
rmdir .svn /s /q
Source: Stackoverflow.com