04.18
This morning I find myself in need of a file that used to exist in an SVN project. The file was deleted several months ago and I don’t have a copy anywhere else. Finding it in my SVN repository turned out to be quite simple.
Run the following command to dump the complete activity log from the project.
> svn log --verbose > myLog.txt
Then simply open the ‘myLog.txt’ file with your favourite editor and hunt for the last mention of the file you need. I’m looking for “register.module.php”, so for me that looks like this:
------------------------------------------------------------------------ r428 | mvoorberg | 2010-11-15 22:06:33 -0700 (Mon, 15 Nov 2010) | 2 lines Changed paths: M /faq.php M /login.action.php D /register.module.php
Use the following command to restore the file to the local filesystem at which point you can copy it out or do whatever you like with it. Notice the version number (427) is one less than the version that included the Delete action above.
> svn up -r 427 register.module.php
Once I copied the file out, I removed it again by simply running:
> svn up
Don’t forget to remove the ‘myLog.txt’ file when you’re done with it.