Subversion never completely deletes a file from the repository. In fact, this is a well requested feature.
You do a svn delete
or svn rm
, and the file is no longer in the working copy. However, it is definitely still there. What's probably is convincing you that the file has been permanently removed is that you're doing something like this:
$ svn co http://repo/svn/project
[...]
$ cd project
$ svn del foo.txt
$ svn commit -m "Removed foo.txt"
committed version 12345
$ svn ls http://repo/svn/project/foo.txt
No such file
This is true. File foo.txt
is no longer in the most current revision of Subversion.
Maybe you did something like this:
You knew that the file isn't in revision 12345 because you removed it. However, let's look at revision 12344. The file should still be there in THAT revision:
$ svn ls -r12344 http://repo/svn/project/foo.txt
No such file
Look, revision isn't in revision 12344. Therefore, it has been permanently deleted.
Not so fast, Bunky. What you requested is revision 12344 of the file in the current revision of the repository layout. What you need to do is understand the difference between the file revision and the repository revision. This is called revision pegging, and can be one of the more difficult concepts in Subversion.
What you want to see is the file in the 12,344th revision of the REPOSITORY. To do that, you put a @
at the end of the repository URL:
$ svn ls http://repo/svn/project/foo.txt@12344
foo.txt
Now, we can see the file because it's in the 12,344th revision of that repository layout. If you need to undelete the file, you can always copy the revision of the file you want from the pegged revision of the repository layout:
$ svn cp -r12344 -m"undeleting foo.txt" \
http://repo/svn/project/foo.txt@12344 \
http://repo/svn/project
This will copy revision 12344 of file foo.txt
at the 12,344th revision of the repository to the current revision of the repository.
The easiest way to find files that have been deleted is to look at svn log
:
$ svn log -rHEAD -v http://repo/svn/project/foo.txt
r12345 | dweintraub | [...]
Removed foo.txt
D /project/foo.txt
-----------------------------------------------------
I deleted file `foo.txt in revision 12345. Therefore, it still existed in revision 12344. Good to know if I need to undelete the file.
Yes, it might seem silly in this instance that I have to request the revision of the file and the Subversion layout because they're both the same. However, that's not always going to be the case. Files get moved around and copied, deleted, and undeleted. The version of the file I want might not be the same as the repository version I'm looking for.
remove
ordel
orrm
won't remove the history from the repository. – Wakidel
means after the next update to the working copy, the file will be there again. – Precisecommit
to delete it from your working copy. – Waki