SVN Client Use Tutorial under Linux (full)

Keywords: svn PHP Linux

1. Introduction to Svn

The full name of SVN is Subversion, which is version control system. Like CVS, SVN is a cross-platform software that supports most common operating systems. As an open source version control system, Subversion manages data that changes over time. These data are placed in a central repository. This archive is very much like a regular file server, but it remembers every file change. So you can restore the file to the old version, or browse the history of the file changes. Subversion is a general-purpose system that can be used to manage any type of file, including program source code.

2. Svn Installation

Installation tutorial: Installing SVN Server under Linux

3. Svn usage

3.1. Check out files to local directories

svn checkout svn_path local_path
//For example:
svn checkout svn://192.168.1.131/45dian/brand
//It is recommended to add local directories:
svn checkout svn://192.168.1.131/45dian/brand ./brand/
//Abbreviation 
svn co

3.2. Adding new files to the version Library

svn add file
//For example (add test.php): 
svn add test.php 
//Add all php files in the current directory
svn add *.php
//Add the user directory (and add all content (recursively) in the directory)
svn add user

When the addition is complete, it needs to be submitted to the version library.

3.3. Submit the changed files to the version Library

svn commit -m 'Note Content' [-N] [--no-unlock] PATH
//Abbreviation 
svn ci
//Submit folders and directories
svn ci -m 'Add new files' test.php
svn ci -m 'Add a new directory(recursion)' user

3.4. Locking/unlocking

svn lock -m 'Locked comment content' [--force] PATH
//For example:
svn lock -m "Lock file" test.php
//Unlock contents
svn unlock PATH 

3.5. Updated version

Before modifying a file, you must first update the version library, then modify the file, and then submit it.
If the prompt expires at the time of submission because of conflict, you need to update, modify the file, then clear SVN resolution, and finally commit.

svn update -r m PATH
//Update to the latest version:
svn update
//Restore files to historical version 200
svn -r 200 test.php
//Update test.php to the latest version
svn update test.php
//Abbreviation
svn up

3.6. View file or directory status

svn status PATH
//Display the status of files and subdirectories, not normally displayed
// Not in the control of svn
// M Content Modified
// C clashes
// A Reservation Add to Version Library
// K is locked
svn status -v PATH
//For example:
svn status
svn status -v
//Abbreviation
svn st

3.7. Delete files

svn delete PATH -m 'Note Content'
//For example:
svn delete svn://192.168.1.133/45dian/brand/test.php-m'Delete files in svn'
//Or (recommended)
svn delete test.php
svn ci -m 'Submit deleted files'
//Abbreviation
svn (del,remove,rm)

3.8. View logs

svn log PATH
//For example:
//Display the modification record of this file and the change of version number
svn log
svn log test.php

3.9. View File Details

svn info PATH
//For example:
//Display information about the current directory
svn info
//Display test.php file information
svn info test.php

3.10. Compare file and directory differences

svn diff PATH
//Compare modified files with the latest version in the warehouse
svn diff test.php

//Contrast between versions
svn diff -r m:n PATH
//Comparisons between Version m and Version n
svn diff -r 200:201 test.php

3.11. Merge the differences between the two versions into the current file

//Merge m and n versions into the current file
svn merge -r m:n path
//for example
svn merge -r 200:201 test.php
//But conflicts usually arise and need to be dealt with.

3.12, SVN Help

svn help
svn help ci

3.13. Add Folders to Version Warehouse

//Add folders to svn version repository
svn mkdir PATH
//Equivalent to
mkdir work
svn add work -m 'add folders'

3.14. Code Base URL Change

svn switch (sw): Update working copies to different URL s.
Usage: 
    1,switch URL [PATH]
    2,switch –relocate FROM TO [PATH...]

1. Update your working copy and map it to a new URL, which behaves much like "svn update", and will also map it to a new URL.
     Files on the server are merged with local files. This corresponds to a working copy to a branch or tag in the same warehouse.
     Method.
2. Rewrite the URL metadata of the working copy to reflect the change on the simple URL. When the root URL of the warehouse changes 
    (e.g. scenario name or host name change), but the working copy is still used when mapping to the same directory in the same warehouse
    This command updates the corresponding relationship between the working copy and the warehouse.

3.15. Conflict Resolution

svn resolved: Remove the "conflict" state of the working copy's directory or file.
Usage: resolved PATH...
Note: This subcommand does not resolve conflicts grammatically or remove conflict markers; it just removes conflicts
 Relevant files, and then allow PATH to submit again.

Posted by freephoneid on Fri, 29 Mar 2019 07:12:28 -0700