SVN View History
Through svn commands, you can retrieve past versions based on time or revision number, or view the specific modifications made in a particular version. The following four commands can be used to view svn history:
svn log:Used to display the revision's author, date, path, and so on.
-
svn diff:Used to display line-level detailed information of specific modifications.
-
svn cat:Retrieve a file at a specific revision and display it on the current screen.
-
svn list:Display a directory or files that exist in a specific revision.
1、svn log
Can display all information. If you only want to view the information between two specific revisions, you can use:
root@example:~/svn/example01/trunk# svn log -r 6:8 ------------------------------------------------------------------------ r6 | user02 | 2016-11-07 02:01:26 +0800 (Mon, 07 Nov 2016) | 1 line change HelloWorld.html first. ------------------------------------------------------------------------ r7 | user01 | 2016-11-07 02:23:26 +0800 (Mon, 07 Nov 2016) | 1 line change HelloWorld.html second ------------------------------------------------------------------------ r8 | user01 | 2016-11-07 02:53:13 +0800 (Mon, 07 Nov 2016) | 1 line SVN readme. ------------------------------------------------------------------------
If you only want to view the revision modification information of a certain file, you can usesvn logFile path.
root@example:~/svn/example01# svn log trunk/HelloWorld.html ------------------------------------------------------------------------ r7 | user01 | 2016-11-07 02:23:26 +0800 (Mon, 07 Nov 2016) | 1 line change HelloWorld.html second ------------------------------------------------------------------------ r6 | user02 | 2016-11-07 02:01:26 +0800 (Mon, 07 Nov 2016) | 1 line change HelloWorld.html first. ------------------------------------------------------------------------ r5 | user01 | 2016-11-07 01:50:03 +0800 (Mon, 07 Nov 2016) | 1 line ------------------------------------------------------------------------ r4 | user01 | 2016-11-07 01:45:43 +0800 (Mon, 07 Nov 2016) | 1 line Add function to accept input and to display array contents ------------------------------------------------------------------------ r3 | user01 | 2016-11-07 01:42:35 +0800 (Mon, 07 Nov 2016) | 1 line ------------------------------------------------------------------------ r2 | user01 | 2016-08-23 17:29:02 +0800 (Tue, 23 Aug 2016) | 1 line first file ------------------------------------------------------------------------
If you want to get directory information, you need to add-v。
If you want to display directory information limited to N records, usesvn log -l N -v。
root@example:~/svn/example01/trunk# svn log -l 5 -v ------------------------------------------------------------------------ r6 | user02 | 2016-11-07 02:01:26 +0800 (Mon, 07 Nov 2016) | 1 line Changed paths: M /trunk/HelloWorld.html change HelloWorld.html first. ------------------------------------------------------------------------ r5 | user01 | 2016-11-07 01:50:03 +0800 (Mon, 07 Nov 2016) | 1 line Changed paths: M /trunk/HelloWorld.html ------------------------------------------------------------------------ r4 | user01 | 2016-11-07 01:45:43 +0800 (Mon, 07 Nov 2016) | 1 line Changed paths: M /trunk/HelloWorld.html Add function to accept input and to display array contents ------------------------------------------------------------------------ r3 | user01 | 2016-11-07 01:42:35 +0800 (Mon, 07 Nov 2016) | 1 line Changed paths: A /trunk/HelloWorld.html (from /trunk/helloworld.html:2) D /trunk/helloworld.html ------------------------------------------------------------------------ r2 | user01 | 2016-08-23 17:29:02 +0800 (Tue, 23 Aug 2016) | 1 line Changed paths: A /trunk/helloworld.html first file ------------------------------------------------------------------------
2、svn diff
Used to check the details of historical modifications.
- Check local modifications
- Compare working copy with repository
- Compare repository with repository
(1) If you use svn diff without any parameters, it will compare your working files with the "pristine" copy cached in .svn.
root@example:~/svn/example01/trunk# svn diff Index: rules.txt =================================================================== --- rules.txt (revision 3) +++ rules.txt (working copy) @@ -1,4 +1,5 @@ Be kind to others Freedom = Responsibility Everything in moderation -Chew with your mouth open
(2) Compare working copy and repository
Compare your working copy with the file rule.txt at revision 3 in the repository.
svn diff -r 3 rule.txt
(3) Compare repository with repository
Pass two revision numbers separated by a colon via -r (revision), and the two revisions will be compared.
Compare the changes of this file between revisions 2 and 3 in the svn working copy.
svn diff -r 2:3 rule.txt
3、svn cat
If you just want to check a past version without viewing the differences, you can use svn cat
svn cat -r 版本号 rule.txt
This command will display the content of the file at that revision number.
4、svn list
svn listYou can view files in the directory without downloading them to a local directory:
$ svn list http://192.168.0.1/example01 README branches/ clients/ tags/Other extensions