SVN client tutorial under Linux (full)

1. Svn introduction

The full name of SVN is subversion, i.e. 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. This data is placed in a central repository. The archive is much like an ordinary file server, but it remembers every file change. In this way, you can restore the file to the old version or browse the change history of the file. 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 use

3.1. Check out the file to the local directory

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

3.2. Add a new file 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 user directory (add all contents under the directory (recursively)
svn add user

After adding, you need to submit to the version library.

3.3. Submit the changed documents to the version library

svn commit -m 'Note Content ' [-N] [--no-unlock] PATH
//Abbreviation
svn ci
//Submission folder and directory
svn ci -m 'Add new file' test.php
svn ci -m 'Add new directory(recursion)' user

3.4 locking / unlocking

svn lock -m 'Lock comment content' [--force] PATH
//For example:
svn lock -m "Lock file" test.php
//Unlock content
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.
If you are prompted to expire when submitting because of a conflict, you need to update and modify the file first, then clear svn resolved, and then submit the commit.

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

3.6. View file or directory status

svn status PATH
//Displays the status of files and subdirectories, not normally
// ?  Not under the control of svn
// M content modified
// C conflict
// Add A subscription to the version Library
// K locked
svn status -v PATH
//For example:
svn status
svn status -v
//Abbreviation
svn st

3.7 deleting 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 log

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:
//Displays information about the current directory
svn info
//Show test PHP file information
svn info test.php

3.10. Differences in comparison documents and directories

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

//Comparison between versions
svn diff -r m:n PATH
//Compare the difference 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
//However, conflicts usually arise and need to be handled

 

3.12 SVN help

svn help
svn help ci

3.13. Add folder in version warehouse

//Add folder in 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 the working copy to a different URL.
Usage:

    1,switch URL [PATH]
    2,switch –relocate FROM TO [PATH...]

1. Update your working copy and map it to a new URL. Its behavior is very similar to "svn update", which will also
Merge files on the server with local files. This is to map the working copy to a branch or tag in the same warehouse
Method.
2. Rewrite the URL metadata of the working copy to reflect changes on the simple URL. When the root URL of the warehouse changes
(for example, the scheme name or host name changes), but the working copy is still mapped to the same directory in the same warehouse
This command updates the correspondence between the working copy and the warehouse.

3.15 conflict resolution

svn resolved: removes the conflicting state of the directory or file of the working copy.
Usage: resolved PATH
Note: This subcommand will not resolve conflicts or remove conflict markers according to syntax; It just removes the conflict
Relevant files, and then let PATH submit again.
--------
Copyright notice: This article is the original article of CSDN blogger "Martin Luther bin", which follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this notice for reprint.
Original link: https://blog.csdn.net/qq_27968607/article/details/55253997

Keywords: Linux svn server

Added by NYSiRacer on Mon, 03 Jan 2022 16:52:58 +0200