Friday, 12 June 2009

Removing .svn directories and getting "Operation not permitted" on OSX

I had some code that I'd checked out, but now wanted to check back
into another repository. The cleaner way to do this would have been to
export the directories I wanted, so that .svn directories didn't get
created. But I no longer had access to the original repositories, so I
have to remove the .svn directories recursively.

And I found this bit of shell scripting would work on OSX (currently
on 10.5.7) after moving to the top of the directory tree where i
wanted to delete .svn:

find . -name .svn -exec rm -rf {} \;


most of the time.

Except when I would get "Operation not permitted" with some directory
trees. Turns out these files under .svn had the immutable flag set on
them, and we have to use the 'chflags' command with the 'nouchg' to
remove the immutable flag.

chflags -R nouchg [name of directory containing .svn directories]

eg: chflags -R nouchg MyProject/



No comments: