SVN: Code rollback

Source: Internet
Author: User

First case: when the Code has not been submitted


In this case, svn revert can be used to cancel the previous modification.

# Svn revert [-R] somefile

The relative path of somefile can be a directory or a file, or an absolute path.

When somefile is a single file, you can directly svn revert somefile;

When somefile is a directory, you need to add the parameter-R (Recursive, Recursive). Otherwise, only the directory somefile will be changed.

In this case, you can also use the svn update command to cancel the previous modification, but it is not recommended. Because svn update will connect to the repository server, it takes time.

Note: svn revert is inherently dangerous because it aims to discard uncommitted changes. Once you select recovery, Subversion cannot retrieve uncommitted changes.


Case 2: the change has been submitted


In this case, run the svn merge command to perform rollback. The rollback procedure is as follows: 1. ensure that we get the latest code: svn update.

Assume that the latest version is 28.

2. Find the exact version number for rollback:

Svn log [somefile]

If there are many logs, you can use the -- limit parameter.

Svn log -- limit 10 [somefile]

Assume that the version number to be rolled back is 25 Based on the svn log. The somefile here can be a file, directory, or the entire project.

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

Svn diff-r 28:25 [somefile]

3. Roll Back to version 25:

Svn merge-r 28:25 [somefile] for the sake of insurance, confirm the rollback result again: svn diff [somefile] found correct and submitted. 4. Submit rollback: svn commit-m "Revert revision from r28 to r25, because ..."

The submitted version is changed to 29.


The preceding operations are summarized as follows: 1. svn update, svn log, find the latest revision) 2. find the version number rollback revision you want to roll back.) 3. roll back and forth with svn merge: svn merge-r 28:25 somefile

Note: Although svn up-r 25 somefile can also roll back the file, it cannot be submitted because it is not the latest version. You must update, copy, and submit the file first, it is not recommended.


Supplement:

Svn ignores files or folders

Svn propset svn: ignore '*' template_c/



This article is from the "phper" blog, please be sure to keep this source http://janephp.blog.51cto.com/4439680/1300561

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.