Roll back or revert entire svn repository to an older revision

前端 未结 14 1350
时光取名叫无心
时光取名叫无心 2020-12-04 06:53

I messed up on my SVN repository and now need to revert the entire repository from revision 28 to 24 and don\'t want to deal with diffs or conflicts. Is there a quick and si

相关标签:
14条回答
  • 2020-12-04 07:33

    A "reverse" merge may be what you need. See "undoing changes" section of svn book.

    E.g. svn merge -r 28:24 [path to svn]

    0 讨论(0)
  • 2020-12-04 07:34
    Example:
        Rev 100 all is working great        
        Rev 101 somebody really corrupted the dir structure and / or merged in bad changes, etc.
        Rev 102 You delete /trunk
        Rev 103 You copy /trunk@100 to HEAD
            You now have a /trunk that reflects only Rev 100 and 103. Not 101 or 102.
    
    svn del svn://[RepoName]/trunk -m "removing issue in HEAD"
    svn copy svn://[RepoName]/trunk@100 svn://[RepoName]/trunk -m "Copy of correct revision of trunk to HEAD"
    
    0 讨论(0)
  • 2020-12-04 07:35

    If the folder structure of your application hasn't changed, checkout the old revision and replace the .svn folders from the latest revision into the checked out old revision. Now you can commit the "older" version.

    0 讨论(0)
  • 2020-12-04 07:38

    If you really need to wipe 'evidence' that the files ever existed, you need to do the svndump/svnload actions described above.

    In a 'normal' situation, where you made a mistake, you need to use reverse merge. This make sure that undoing the changes after r24 can also be reverted, diffed, etc.

    The command below should work to undo your changes (you need to commit the result of the merge to reflect the merge in the repository)

    svn merge -r 28:24
    
    0 讨论(0)
  • 2020-12-04 07:39

    If you have access to the SVN server, you can just edit path/db/current, put the old revision number you want to revert to (here: 24) there, and remove no longer needed revision files (i.e. 25, 26, 27, 28) from path/db/revs/0/. At least this worked for me today, after I had accidentally removed a directory in the repository.

    0 讨论(0)
  • 2020-12-04 07:41

    here is how I would start to do it. Brutal, yes, but its the only thing guaranteed to completely ignore collisions and keep revisions history intact.

      cd /scratchdir 
      svn co -r good svn://repository
      cd /hosed_project
      svn up -r HEAD
      cat >> /tmp/cp.sh 
      ORIG=$1
      TARG=$( echo $ORIG | sed 's/\/scratchdir\///' ); 
      cp $ORIG /hosed_project/$TARG;
      ^D
      chmod u+x /tmp/cp.sh
      find /scratchdir -not -wholename "*/.svn*" -exec /tmp/cp.sh {} \;
    

    Note, this is not the "normal" way IMO, the normal way is to create a branch from an old version, and then merge that branch back in to the head. ( at least, that's how It used to work )

    Edit: the above code is untested, do NOT run it verbatim

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