Undo svn add without reverting local edits

I accidentally ran svn add * and added a bunch of files that shouldn't be in the repository. I also have local edits in some files that I want to keep. Is there a simple way to just undo the svn add without reverting the local edits? The main suggestion I see on Google is svn revert, which supposedly undoes the local edits.


Solution 1:

That would be:

svn rm --keep-local

The same thing happened to me. :-P

Many people have commented that you should use:

svn rm --keep-local FILENAME

to apply the command on one or many files, instead of everything, which may have unintended side-effects.

Solution 2:

If those files are under a directory which has not been committed yet, you can remove the whole directory contents from the next commit by doing:

svn delete --keep-local /path/to/directory

However, if those files are already in the repository and now contain changes that you do not want to commit, you can commit the rest of the files using changelists:

svn changelist somename /file/to/be/committed
svn commit --changelist somename

Solution 3:

You can fix your checkout in the following way:

  1. Backup your local files
  2. Revert the SVN checkout
  3. Restore the files

-

rsync -av --exclude .svn/ YOURDIR/ YOURDIR.bak
svn revert -R YOURDIR
rsync -av YOURDIR.bak/ YOURDIR