I have a file as shown below in an SVN repo that I would like to revert to a previous version. What is the way to do this in SVN? I want only downgrade this particular file to a
svn revert filename
this should revert a single file.
The best way is to:
svn merge -c -RevisionToUndo ^/trunk
This will undo all files of the revision than simply revert those file you don't like to undo. Don't forget the dash (-
) as prefix for the revision.
svn revert File1 File2
Now commit the changes back.
surprised no one mentioned this
without finding out the revision number you could write this, if you just committed something that you want to revert, this wont work if you changed some other file and the target file is not the last changed file
svn merge -r HEAD:PREV file
If you want to roll back an individual file from a specific revision and be able to commit, then do:
svn merge -c -[OldRev#] [Filename]
ie. svn merge -c -150 myfile.py
Note the negative on the revision number
An alternate option for a single file is to "replace" the current version of the file with the older revision:
svn rm file.ext
svn cp svn://host/path/to/file/on/repo/file.ext@<REV> file.ext
svn ci
This has the added feature that the unwanted changes do not show up in the log for this file (i.e. svn log file.ext).
Just adding on to @Mitch Dempsy answer since I don't have enough rep to comment yet.
svn export -r <REV> svn://host/path/to/file/on/repos --force
Adding the --force will overwrite the local copy with the export and then you can do an svn commit to push it to the repository.