Better way to revert to a previous SVN revision of a file?

前端 未结 9 1025
小鲜肉
小鲜肉 2020-12-04 04:34

I accidentally committed too many files to an SVN repository and changed some things I didn\'t mean to. (Sigh.) In order to revert them to their prior state, the best I coul

相关标签:
9条回答
  • 2020-12-04 05:13

    Check out "undoing changes" section of the svn book

    0 讨论(0)
  • 2020-12-04 05:15

    svn merge will merge revisions, not revert them. i.e. if you have some addition in your HEAD version then merge that with a previous revision, then the change will persist.

    I use svn cat then redirect it into the file:

    svn cat -r 851 l3toks.dtx > l3toks.dtx
    

    Then you have the 851 content in that file and can check it back in.

    0 讨论(0)
  • 2020-12-04 05:16
    svn merge -r 854:853 l3toks.dtx
    

    or

    svn merge -c -854 l3toks.dtx
    

    The two commands are equivalent.

    0 讨论(0)
  • 2020-12-04 05:24

    I recently had to revert to a particular revision to debug an older build and this worked like magic:

    svn up -r 3340 (or what ever your desired revision number)
    

    I had to resolve all conflicts using "tc" option as I did not care about local changes (checked in everything I cared about prior to reverting)

    To get back to head revision was simple too:

    svn up
    
    0 讨论(0)
  • 2020-12-04 05:25

    What you're looking for is called a "reverse merge". You should consult the docs regarding the merge function in the SVN book (as luapyad, or more precisely the first commenter on that post, points out). If you're using Tortoise, you can also just go into the log view and right-click and choose "revert changes from this revision" on the one where you made the mistake.

    0 讨论(0)
  • 2020-12-04 05:27

    If you use the Eclipse IDE with the SVN plugin you can do as follows:

    1. Right-click the files that you want to revert (or the folder they were contained in, if you deleted them by mistake and you want to add them back)
    2. Select "Team > Switch"
    3. Choose the "Revision" radion button, and enter the revision number you'd like to revert to. Click OK
    4. Go to the Synchronize perspective
    5. Select all the files you want to revert
    6. Right-click on the selection and do "Override and Commit..."

    This will revert the files to the revision that you want. Just keep in mind that SVN will see the changes as a new commit. That is, the change gets a new revision number, and there is no link between the old revision and the new one. You should specify in the commit comments that you are reverting those files to a specific revision.

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