How to remove subversion (SVN) info from a project
Posted by Ivan Storck | Filed under Web Design
Sometimes when I’m coding I need to remove all the subversion (SVN - a source code version control program, which if you’re a non-programmer, you could also use for any documents you want to version control) information from the project. Perhaps you’ve copied the code to another directory and want to start a new source repository, or have some other reason. I wrote a short ruby script to help called ’stripsvn’ Here it is:
#!/usr/bin/env ruby
# note above line may need to be changed on linux - use 'which ruby' to find path to ruby
# by Ivan Storck 13 February 2008
puts "The current directory is #{ENV["PWD"]}"
puts "About to delete ALL subversion info from this directory and all directories below"
print "WARNING - this is permanent! Type YES to continue:"
confirm = gets
if confirm == "YES\n" or confirm == nil
puts `find . -name .svn -type d -print0 | xargs -0 rm -rf`
puts "Deleted all subversion info"
else
puts "Command aborted"
end
I put this in a file called stripsvn in a folder called bash_scripts (I know, it’s not written in bash, it’s in ruby) - that was in my path from the command line so I could just type stripsvn at the terminal and run the command. You could put it anywhere, but it’s useful to have a folder that you put scripts you’ve wrote in, and have it included in your path. You might also have to chmod 755 stripsvn to make it executable. This short script is a good example of using mostly ruby to write a useful shell script and only use bash or what I’d call “unix” commands when you have to. It’s all ruby except for the line with the find that actually does the deleting.
Tags: ruby, subversion, svn, Web Design





February 12th, 2008 at 6:34 pm
moving on to git? (with “everyone” else?)
February 13th, 2008 at 1:23 am
Chris, are you offering me a personal tutorial? (via chat or IRC?) At least share some links, brother!
February 13th, 2008 at 11:46 pm
heres a funny talk from linus:
http://www.youtube.com/watch?v=4XpnKHJAok8
im not using it any time soon (none of my work is that distributed.) Also check out svn export
http://svnbook.red-bean.com/en/1.4/svn.ref.svn.c.export.html
June 8th, 2008 at 6:48 am
Thanks Ivan, your script to get rid of the .svn directory saved a lot of time and effort for me. -Raveesh
August 17th, 2008 at 1:18 am
Thanks that helped me get rid of my NetBeans svn bindings!
September 15th, 2008 at 7:42 pm
Thanks Ivan - that script was exactly what I needed! Thanks for writing it.