Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename file on SVN whilst keeping history?

Having some trouble renaming a file in SVN whilst keeping the history.

Used this thread, but I'm pretty sure I just made a new file, and deleted the old one... (How to rename a file using svn?)

And following the comments, I did create a new file with the new file name I wanted.

touch newfilename
svn rm newfilename --force
svn mv oldfilename newfilename

Which gave me:

A    newfilename
D    oldfilename

Using svnX 0.9.13

like image 716
yingers Avatar asked Mar 16 '17 18:03

yingers


3 Answers

Since you have tortoisesvn tag in your question, this is how to do it using TortoiseSVN 1.9.7:

  1. in your working copy folder right click on the file you want to rename and select "TortoiseSVN > Repo-browser"

  2. in the Repo-browser window that opens, right click on the file you want to rename and select "Copy to..."

  3. a dialog box appears asking you for the new file name (the file is shown with its full path), don't change the path, just change the file name and click OK.

  4. still in the Repo-browser window, right click on the old file and select "Delete"

Done, the file was renamed and it kept all its history.

  1. go back to your working copy folder, right click on the folder and select "TortoiseSVN > Check for Modification", then click "Check repository" button, right click on the renamed file and select "Update"
like image 110
Marco Demaio Avatar answered Nov 19 '22 02:11

Marco Demaio


Rename in Subversion is implemented as a copy with history (to create the new file) plus a delete (deleting the original).

If you run svn status, you should see the status of newfilename as A + which indicates that newfilename has been added, but with history coming along for the ride.

If you're seeing that, then you've done it right and you can commit your changes. I recommend committing at the directory level, don't commit the individual files - that way, your rename operation is captured within a single revision.

like image 34
alroc Avatar answered Nov 19 '22 01:11

alroc


If you execute this then you can easily rename your SVN files keeping its history.

svn move oldfilename newfilename
svn status
D      oldfilename
A +    newfilename

If you see this then the file changes history is preserved.

like image 7
Pradeep Ravilla Avatar answered Nov 19 '22 00:11

Pradeep Ravilla