ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

svn代码回滚

2019-05-14 18:43:32  阅读:306  来源: 互联网

标签:svn 回滚 代码 merge command commit changes revision


原文:https://blog.mafr.de/2008/05/13/revert-a-commit-in-svn/

---------------------------------------------------------------------

Reverting a Commit in Subversion

Posted on May 13, 2008by 

Once in a while, someone commits a revision that has to be rolled back later for some reason. Some teams do that as a matter of policy when people check in broken code that doesn’t compile or isn’t able to run all test cases successfully. Since Subversion (and similar revision control systems) are designed to never lose changes, this isn’t easily possible.

 

If a commit really has to disappear without traces for some reason, the only way is to import your repository into a new one leaving out the offending commit. That’s a rather drastic measure causing all kinds of problems with existing working copies, so use it with great care.

The approach used more often is to commit a new revision that takes back earlier changes. This is like undoing all changes manually and committing them in the usual way. The offending changes are still in the history, but don’t do harm anymore.

This command rolls back changes made in revision N, using a reverse merge:

svn merge -c -N .

Note the minus character in front of N. This is the same as the following command (which also works with older subversion clients):

svn merge -r N:N-1 .

Rolling back multiple changes (let’s say revisions LOW to HIGH, both inclusive) works the same way:

svn merge -r HIGH:LOW-1 .

Afterwards examine the changes made to the working copy and commit them.

To understand what’s happening here requires some background on what the merge command does conceptually: It records which changes have to be made to revision N to turn it into revision N+1 (called a delta) and applies it to the working copy. That’s not what we want in our scenario, so we reverse the usual order of revisions on the command line. Effectively, we tell the merge command to create a delta the other way round. The result is a "rewinding" of the code base.

标签:svn,回滚,代码,merge,command,commit,changes,revision
来源: https://www.cnblogs.com/oxspirt/p/10863793.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有