Wednesday, February 20, 2008

Recovering a file using subversion

Today I've just realized I actually deleted a file which is used in on of my projects. After googling for a while I found this http://svnbook.red-bean.com/en/1.2/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.resurrect which basically tells how to recover a lost file.

To sum it up, you have to first find out which version the file still exists in (that would be the version just BEFORE the file was deleted). To do that use svn log to look for it. I searched for it with something like this:

svn log --verbose | grep -B 10 name_of_file


The -B option is how many lines before the found line should be displayed. Quite important as the version number is actually on top of the log and not on each file line.

Once you know which version you have to recover from, it is a small matter of copying that file from the repository with a svn copy command:

svn copy --revision num_of_revision http://path/to/file/in/repository ./name_of_file


The file would be recovered and you'd have to commit it again to the repository so that it'd be available for everyone.

No comments:

Is Blogging No Longer a Thing?

As I embark on my new journey to learn the Rust programming language, I find myself pondering—where have all the blogs gone? In search of pr...