Tutorial :rename file and replace old file name with file from previous revision in Subversion


I have a Subversion branch checked out using TortoiseSVN in Windows. I have a file, call it myfile.txt, that I want to rename, say to mynewfile.txt. I want to keep myfile.txt around, however, and just revert it back to a previous revision, say r15. So, I want myfile.txt to have content from r15 and mynewfile.txt to have myfile.txt's content from rHEAD. I was hoping I could somehow do this with Subversion commands so that the history of the file is preserved. That way, when I commit this and you look at the modifications, you can see mynewfile.txt is just a rename of myfile.txt, and myfile.txt now has its old content from r15. Is this possible? Should I just rename myfile.txt -> mynewfile.txt and then remake myfile.txt, manually copying content from r15 into it?


svn cp myfile.txt mynewfile.txt  svn co -r15 myfile.txt  svn commit  

I believe that would preserve the history as you wish.

EDIT: TortoiseSVN, did not realize! New steps:

  1. Open the Repo Browser and Right-click your myfile.txt
  2. Select "Copy to..." and choose mynewfile.txt as the new name.
  3. Right-click myfile.txt in a checked-out copy and choose "Update to revision" and select 15.
  4. Commit.


You need a second working copy at the old revision(It is sufficient to copy the directory and update the single file only). Then you need to perform the following steps:

  • In the HEAD working copy Choose rename from the svn context menu to rename the file
  • go to the OLD working copy and drag the old file to the HEAD working copy with the right mouse button
  • chose svn copy versioned items here from the appearing menu
  • commit (make sure the text status says "replaced(+)" for the old file and "added(+)" for the new file)

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »