SVN view history information
Through the svn command, you can retrieve past versions based on time or revision number, or the specific modifications made in a certain version. The following four commands can be used to view svn history:
-
svn log: Used to display the svn version author, date, path, etc.
-
svn diff: Used to display line-level details of specific modifications.
-
svn cat: Retrieve and display a certain file at a specific version on the current screen.
-
svn list: Display the files in a directory or a certain version.
1. svn log
Can display all information. If you only want to view information between two specific versions, you can use:
root@runoob:~/svn/runoob01/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 version modification information of a certain file, you can use svn log File path.
root@runoob:~/svn/runoob01# 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 information about a directory, add -v.
If you want to display directory information limited to N records, use svn log -l N -v.
root@runoob:~/svn/runoob01/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 "original" copy cached in .svn.
root@runoob:~/svn/runoob01/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 the file rule.txt in your working copy with version number 3 in the repository.
svn diff -r 3 rule.txt
(3) Compare repository with repository
Pass two revision numbers separated by a colon through -r (revision), and these two versions will be compared.
Compare the changes of this file between version numbers 2 and 3 in the svn working version.
svn diff -r 2:3 rule.txt
3. svn cat
If you only want to inspect a past version without viewing their differences, you can use svn cat
svn cat -r 版本号 rule.txt
This command will display the content of the file at that version number
4. svn list
svn list You can view the files in a directory without downloading the files to the local directory:
$ svn list http://192.168.0.1/runoob01
README
branches/
clients/
tags/