SVN code rollback issue

Source: Internet
Author: User
Tags diff rollback svn svn update

In the first case: When the code has not yet been submitted

In this case, you can use SVN revert to cancel the previous modification.

# svn revert [-r] Somefile

Where somefile can be either a relative path (a directory or a file) or an absolute path.

When Somefile is a single file, the direct svn revert somefile on the line;

When Somefile is a directory, you need to add the parameter-R (recursive, recursion), otherwise it will only change somefile this directory.

In this case, you can also use the SVN Update command to undo previous modifications, but not recommended. Because SVN update is going to connect to the warehouse server, it's time consuming.

Note: The SVN revert itself is inherently dangerous because it is intended to discard uncommitted modifications. Once you have chosen to recover, subversion has no way to retrieve uncommitted changes.

Second: Changes have been submitted

In this case, rollback is done with the SVN Merge command, and the rollback process is as follows:

1, to ensure that we get the latest code:

SVN update

Suppose the latest version number is 28.

2, and then find the exact version number to roll back:

SVN log [somefile]

If log a lot, you can use the parameter--limit

SVN log--limit [somefile]

Assuming that the version number to be rolled back according to the SVN log logs is 25, the somefile can be a file, a directory, or an entire project

If you want to know more about the situation, you can use the

SVN diff-r 28:25 [Somefile]

3, roll back to version number 25:

SVN merge-r 28:25 [Somefile]

For insurance purposes, reconfirm the result of the rollback:

SVN diff [Somefile]

Found correct, submitted.

4. Submit rollback:

SVN commit-m "Revert revision from R28 to R25,because of ..."

After the submission, the version becomes 29.

The above actions are summarized as follows: three

1. SVN update,svn log, find the latest version (latest revision)

2. Find the version number you want to roll back (rollback revision)

3. Roll back and forth with svn merge: svn merge-r 28:25 somefile

Note: Although the SVN up-r Somefile can also rollback the file, it is not recommended to use it when the submission is not available because it is not the latest version and it needs to be updated, copied, and resubmitted.

Add:

SVN ignores files or folders

SVN propset svn:ignore ' * ' template_c/

Author: 51cto Blog phper-a little bit every day

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.