Wednesday, March 31, 2010

How to undo changes made using ' svn add '

If you want to add a new file/directory to an svn repository, you first specify the new file/directory using the command

$svn add 'file/directory name'

It is important to note that the change does not propagate to the server until you issue an 'svn commit'

For any reason, if you would like to revert the addition of file/directory, just follow these

1. If it is a directory, go to the directory and delete the directory named '.svn'
$ rm -rf .svn
Go to the parent directory and edit the file .svn/entries and delete the entry corresponding to the directory you added using 'svn add'. Be very careful while editing the file as it contains the metadata used by svn in a particular format

2. If it is a file, go to the .svn directory in the directory which contains the file and edit the file entries and remove the entry corresponding to the file you added using 'svn add

I just found this by experimentation. However, I am not aware of any other method to revert the changes. If you know of any, please feel free to leave a comment.

No comments:

Post a Comment