问题
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
回答1:
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.
回答2:
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.
回答3:
Since you have tortoisesvn
tag in your question, this is how to do it using TortoiseSVN 1.9.7:
in your working copy folder right click on the file you want to rename and select "TortoiseSVN > Repo-browser"
in the Repo-browser window that opens, right click on the file you want to rename and select "Copy to..."
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.
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.
- 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"
来源:https://stackoverflow.com/questions/42842557/how-to-rename-file-on-svn-whilst-keeping-history