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.

- 23,013
- 32
- 104
- 171
4 Answers
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. (The first command would apply to everything, which may have unintended side-effects.)

- 3,232
- 2
- 21
- 14
-
1This had no effect for me. I ran the code as above (including the trailing period) from the base folder. Not sure if I'm missing something. – zzz Jan 20 '12 at 00:47
-
Agreed - this should be the accepted answer. I just tried this and it worked perfectly. – Ted Middleton May 08 '13 at 16:01
-
8Note thou that you have to add file name to the command so that would be `svn rm --keep-local FILENAME`. The `FILENAME` may use * to match multiple files (if you are lucky enough to have a pattern). – Adam Badura Sep 30 '13 at 08:21
-
@010110110101 "svn revert" worked fine for me. Have you tried that too, before claiming that this here should be the accepted answer? – Elmar Zander Sep 30 '13 at 09:31
-
4warning! - using this command while using svn externals removes all the attached externals as well... – kostja Oct 09 '13 at 14:05
-
2If you commit this, won't the commit include the removal of the file in question from the repo? – jwg Apr 01 '14 at 12:51
-
1// , I have the same question as jwg. I made some edits to a SVN controlled file. I want to keep those edits locally. However, I do _not_ want to remove the file from the repository altogether. I just don't want to push my local edits to the file. – Nathan Basanese Sep 18 '15 at 19:13
-
// , `[~/myrepo]$ svn revert --keep-local connect/svn-repo/hooks/pre-commit Subcommand 'revert' doesn't accept option '--keep-local' Type 'svn help revert' for usage.` – Nathan Basanese Sep 18 '15 at 19:16
-
I think Matthew Lock (and I) should have considered Adam Badura 's comment. – Albert Hendriks Jan 25 '18 at 14:43
-
To use a dot a the end is really a bad advice. This command removes the current directory and ALL files in the current directory from the repository and is not only undoing the "add". Of course all local files are kept. – stema May 15 '20 at 11:15
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

- 2,618
- 1
- 25
- 21
You can fix your checkout in the following way:
- Backup your local files
- Revert the SVN checkout
- Restore the files
-
rsync -av --exclude .svn/ YOURDIR/ YOURDIR.bak
svn revert -R YOURDIR
rsync -av YOURDIR.bak/ YOURDIR

- 1,985
- 20
- 16
-
The final command always creates an extra directory level, i.e. ending up with `YOURDIR/YOURDIR/`, although I think the issue is in the initial backup command creating `YOURDIR.bak/YOURDIR/`. – James Jan 01 '18 at 19:37
-
To avoid that rsync requires a trailing slash on the source directory. I edited the answer. – Brice M. Dempsey Jan 02 '18 at 20:23
I had same problem, i accidentally add a /directory via svn add
that contains the binaries and compiled file. This command actually deletes the directory.
svn rm --force <directory-name>
In my case i don't need the directory so it was safe to delete. If you want to keep the files/directories save then to a place before applying the command and after copy them back

- 4,338
- 10
- 45
- 54