svn code rollback command

There are two cases to cancel the modification of the code:
 
Case 1: Changes are not committed.
In this case, use svn revert to undo the previous changes.
The usage of svn revert is as follows:
# svn revert [-R] something
where something can be a relative path (of a directory or file) or an absolute path.
When something is a single file, just svn revert something directly; when something is a directory, you need to add the parameter -R (Recursive, recursive), otherwise only the something directory will be changed.
In this case, you can also use the svn update command to undo previous changes, but it is not recommended. Because svn update will connect to the warehouse server, which takes time.
Note: svn revert itself is inherently dangerous, since its purpose is to discard uncommitted changes. Once you choose to revert, Subversion has no way to retrieve uncommitted changes.
 
Case 2: Changes have been committed.
In this case, use the svn merge command to roll back. 
   The operation process of rollback is as follows: 
   1. Make sure we get the latest code: 
     svn update 
     Suppose the latest version number is 28. 
   2. Then find out the exact version number you want to roll back: 
     svn log [something]
     Assuming that the version number to be rolled back is 25 according to the svn log log, something here can be a file, a directory or the entire project
     If you want a more detailed understanding, you can use svn diff -r 28:25 [something]
   3. Roll back to version 25:
       svn merge -r 28:25 something
     To be on the safe side, reconfirm the result of the rollback:
       svn diff [something]
     If found to be correct, submit.
   4. Commit rollback:
     svn commit -m "Revert revision from r28 to r25,because of ..." 
     After the commit the version became 29.
   The above operations can be summarized into three steps as follows:
   1. svn update, svn log, find the latest version (latest revision)
   2. Find the version number you want to roll back (rollbak revision)
   3. Use svn merge to roll back: svn merge -r : something

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326019944&siteId=291194637