Question: svn beginner here:

Lets say that I pulled from a svn repo and wrote quite a bit of code. However, I only want to commit half of the files I modified. However, I accidentally used `svn add` on all of them. How do I go back to the previous svn state (before I added all these files) without actually touching my modified code.

I know I can manually use svn delete on one half but I was wondering if there was a faster way to revery back.

Answer: 
I hope you haven't committed your changes yet.

You can *unadd* a file by using the following command:

```
$ svn delete --delete --keep-local $file_name

```

This will unadd the file and at the same time keep the file on the drive.

You can also undo all changes (including all of your adds) with this:

```
$ svn revert -R .

```

This will revert all files and will unadd in any files that you added, but won't delete anything. This will also revert any changes made in files already in the repository. However, changelists can save the day.

You can also create *changelists* in Subversion using the `svn cl` command:

```
$ svn cl FOO $file1 $file2 $file3
$ svn cl FOO $file4 $file5

```

This will create a changelist called `FOO` with the five files above. Notice you can add to changelists by simply giving the changelist name and the new files. To remove a file:

```
$ svn cl --remove $file4

```

This will remove `$file4` from the changelist `FOO`.

```
$ svn cl BAR $file1

```

This will remove `$file1` from changelist `FOO` and put it on changelist `BAR`.

Now, here is where it all comes together...

```
$ svn revert --cl FOO -R .

```

This will revert all files, but ***only the ones in changelist `FOO`***. All other files are not touched. So, you can create a change list of all the files you want to *unadd* and then use the `svn revert` command on that changelist. This will keep your files, but at the same time *unadd* them.

So, create a changelist of all the files you want to *unadd*, and then do a `svn revert` on that changelist.

You could do something like this:

```
 $ svn list | awk '$1 == A' '{print $2}' | tee files_to_unadd_list.txt

```

This will give you a list of all files added to Subversion and put it into a list. You could then edit that list to remove the files you want to keep. The result is a list of files you want to *unadd*.

Then you could process it like thus:

```
$ while read file
do
    svn revert --force --keep-local $file
done < files_to_unadd_list.txt

```

Or, create a change list first:

```
$ while read file
do
    svn cl UNADD $file
done < files_to_unadd_list.txt

```

And then go through that list, verify it, and then:

```
$ svn delete --cl UNADD -R .

```
If your changes contains no svn copy or svn move, one of the easiest way to undo all your svn add and keep your changes is:

1. copy your whole working copy to another place, *excluding* the .svn directory (let's call it wc.new)
2. Do a svn revert on your original working copy
3. copy wc.new back to the original working copy and replacing all files