How to rename file on SVN whilst keeping history?

别说谁变了你拦得住时间么 提交于 2019-12-23 12:18:22

问题


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:

  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"


来源:https://stackoverflow.com/questions/42842557/how-to-rename-file-on-svn-whilst-keeping-history

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!