Svn Show History
* * *
Using SVN commands, you can retrieve past versions based on time or revision number, or view the specific changes made in a particular version. The following four commands can be used to view SVN history:
* **svn log:** Used to display information such as the author, date, and paths of SVN versions.
* **svn diff:** Used to show line-level details of specific modifications.
* **svn cat:** Retrieves and displays the content of a file from a specific version on the current screen.
* **svn list:** Displays the files in a directory or those present in a specific version.
* * *
## 1γsvn log
It can display all information. If you only want to view information between two specific versions, you can use:
root@tutorial:~/svn/tutorial01/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 for a specific file, you can use **svn log** followed by the file path.
root@tutorial:~/svn/tutorial01# 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, use **svn log -l N -v**.
root@tutorial:~/svn/tutorial01/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 file with the "original" copy cached in .svn.**
root@tutorial:~/svn/tutorial01/trunk# svn diffIndex: rules.txt ===================================================================--- rules.txt (revision 3)+++ rules.txt (working copy)@@ -1,4 +1,5 @@Be kind to others Freedom = ResponsibilityEverything in moderation -Chew with your mouth open
**οΌ2οΌγCompare working copy with repository**
Compare your working copy with version 3 of the file rule.txt in the repository.
svn diff -r 3 rule.txt
**οΌ3οΌγCompare repository with repository**
Pass two version numbers separated by a colon via -r(revision), and these two versions will be compared.
Compare the changes in this file between revision 2 and 3 in the SVN working version.
svn diff -r 2:3 rule.txt
* * *
## 3γsvn cat
If you only want to check a past version without viewing their differences, you can use svn cat
svn cat -r Version number rule.txt
This command will display the content of that file under that version number.
* * *
## 4γsvn list
**svn list** allows you to view files in a directory without downloading them to the local directory:
$ svn list README branches/ clients/ tags/
YouTip