Revert a svn folder to a previous revision

前端 未结 4 518
我寻月下人不归
我寻月下人不归 2021-01-31 02:24

To revert a particular folder in SVN to its previous state I currently use the following:

svn rm folder
svn commit -m \'removed folder to revert to previous vers         


        
相关标签:
4条回答
  • 2021-01-31 02:29

    Why not using 'svn merge'? That's why: "Then resolve any conflicts manually[..]"

    If I know 'folder' at revision 268 contains the consistent data I'd like to go on with, why automatically create a merge with potentially inconsistent data only to manually remove those changes later. It's error prone and defeats the purpose of my configuration management tool.

    I.e. I'd prefer the recipe from the original request with a minor improvement. If you use 'svn export' to get the old revision you don't have to remove .svn files:

    svn rm folder
    svn commit -m 'removed folder to revert to previous version' .
    svn export -r 268 http://pathto/repo/folder
    svn add folder
    svn commit -m 'reverted to the previous version' folder
    
    0 讨论(0)
  • 2021-01-31 02:34

    Why not using svn merge?

    Assuming you want to revert from current HEAD (last committed) version to revision 268:

    cd folder
    svn up
    svn merge -r HEAD:268 .
    

    Then resolve any conflicts manually (there should be nothing if there is no local change) and:

    svn commit -m "- reverted to revision 268"
    

    To revert single change (e.g. made in revision 666):

    cd folder
    svn merge -c -666 .
    

    To revert local changes (not committed yet):

    cd folder
    svn revert -R .
    
    0 讨论(0)
  • 2021-01-31 02:34

    You can use svn merge for this task, see http://svnbook.red-bean.com/en/1.1/ch04s04.html#svn-ch-4-sect-4.2 for an example

    0 讨论(0)
  • 2021-01-31 02:37

    you could also use

    svn revert folder/*
    

    which will revert all the file under folder

    0 讨论(0)
提交回复
热议问题