SVN command line basic operations

Source: Internet
Author: User
Tags svn client svn update version control system
Below are some of the svn command lines that I commonly used. I sorted them out. This is useful in version control, so it won't work. Of course, you can also select some SVN graphical interface tool 0 to view the current working directory SVN status Abbreviation: SVN ST1. Run the file checkout to the local directory.
SVN checkout path (path is the directory on the server)
Abbreviation: SVN Co

2. Add new files to the version Library
SVN add File

3. Submit the modified file to the version library.
SVN commit-m "logmessage" [-N] [-- no-unlock] path (if the lock is selected, use the-no-Unlock switch)
Abbreviation: SVN Ci

4. Lock/unlock
SVN lock-m "lockmessage" [-- force] path
SVN unlock path

5. Update to a specific version.
SVN update-r m path
Abbreviation: SVN up

6. view the file or directory status
1) SVN status path (the State of the files and subdirectories under the directory. The normal state is not displayed)
2) SVN status-V path (displays the status of files and subdirectories)
Abbreviation: SVN St

7. delete an object
SVN Delete path-m "delete test FLE"
Abbreviation: SVN (Del, remove, RM)

8. View logs
SVN Log Path

9. View File details
SVN info path

10. Differences
SVN diff path (compare the modified file with the basic version)
SVN diff-r m: N path (differences between version m and version n)
Abbreviation: SVN di

11. Merge the differences between the two versions into the current file.
SVN merge-r m: N path

12. SVN help
SVN help
SVN help Ci

 

 

 

1. Checkout the file to the local directory.
 
SVN checkout path (path is the directory on the server)
Example: SVN checkout SVN: // 192.168.1.1/Pro/Domain

Abbreviation: SVN Co

 

2. Add new files to the version Library
 
SVN add File
Example: SVN add test. php (add test. php)

SVN add *. php (add all PHP files in the current directory)

 

3. Submit the modified file to the version library.
 
SVN commit-M "logmessage" [-N] [-- no-unlock] path (if you choose to keep the lock, use the -- no-Unlock switch)
For example, SVN commit-M "add Test file for my test" test. php

Abbreviation: SVN Ci

 

4. Lock/unlock
 
SVN lock-M "lockmessage" [-- force] path
For example, SVN lock-M "lock test file" test. php

SVN unlock path

 

5. Update to a specific version.
 
SVN update-r m path
For example:
If there is no directory after SVN update, all files in the current directory and sub-directories are updated to the latest version by default.
SVN Update-R 200 test. php (restore the file test. php In the version library to version 200)
SVN update test. php (updated for version library synchronization. If an expiration prompt is prompted during submission, it is because of a conflict. You need to update the file, modify the file, clear SVN resolved, and then submit commit)

Abbreviation: SVN up

 

6. view the file or directory status
 
1) SVN status path (the State of the files and subdirectories under the directory. The normal state is not displayed)
【? : Not under SVN control; M: The content is modified; C: A conflict occurs; A: It is scheduled to be added to the version Library; K: it is locked]
2) SVN status-V path (displays the status of files and subdirectories)
The first column remains the same, the second column displays the working version number, and the third and fourth columns show the last modified version number and modifier.
Note: SVN status, SVN diff, and SVN revert commands can be executed without a network, because SVN is locally deployed. SVN retains the original copy of the local version.
Abbreviation: SVN St
 
7. delete an object
 
SVN Delete path-M "delete test FLE"
For example: SVN delete SVN: // 192.168.1.1/Pro/domain/test. php-M "delete test file"
Or directly delete SVN test. php and then SVN ci-M 'delete test file'. We recommend that you use this
Abbreviation: SVN (Del, remove, RM)
 
8. View logs
 
SVN Log Path

For example, SVN Log Test. php displays all the modification records of this file and changes to its version number.

 

9. View File details
 
SVN info path
Example: SVN info test. php
10. Differences
 
SVN diff path (compare the modified file with the basic version)
Example: SVN diff test. php
SVN diff-r m: N path (differences between version m and version n)
Example: SVN diff-r 200:201 test. php

Abbreviation: SVN di

 

11. Merge the differences between the two versions into the current file.
 
SVN merge-r m: N path
For example, SVN merge-r test. php (merge the differences between version 200 and version 205 to the current file, but there are usually conflicts. You need to handle them)

12. SVN help
 
SVN help

SVN help Ci

 

------------------------------------------------------------------------------

 
The above are common commands. Below are a few
 
------------------------------------------------------------------------------
 
13. List of files and directories in the version Library
 
SVN list path
Displays all files and directories in the path directory that belong to the version library.

Abbreviation: SVN ls

 

14. Create a new directory under Version Control
 
SVN mkdir: Create a new directory under version control.
Usage: 1. mkdir path...
2. mkdir URL...
 
15. Restore local modification
 
SVN revert: restore the original unchanged working copy file (recover most local modifications ). Revert:
Usage: Revert path...
Note: The sub-commands do not access the network and will release the conflict. But it won't be restored.
Deleted directory

16. code library URL change
 
SVN switch (SW): update the working copy to different URLs.
Usage: 1. Switch URL [path]
2. Switch -- relocate from to [path...]
 
1. Update your work copy and map it to a new URL. The behavior is similar to "SVN Update" and
Merge files on the server with local files. This maps the work copy to a branch or tag in the same warehouse.
Method.
2. Rewrite the URL metadata of the working copy to reflect the changes on the simple URL. When the root URL of the Repository changes
(For example, the solution name or host name change), but the working copy is still mapped to the same directory in the same repository.
This command updates the correspondence between the working copy and the warehouse.

17. Conflict Resolution
 
SVN resolved: the "Conflict" Status of directories or files that remove working copies.
Usage: resolved path...
Note: subcommands do not follow the syntax to resolve conflicts or remove conflicting tags. They only remove conflicting tags.
Related files, and then allow the path to be submitted again.

18. output the content of the specified file or URL.
 
If the svn cat target [@ version]... is specified, it will start from the specified version.
SVN cat-r Prev FILENAME> filename (prev is the previous version, you can also write a specific version number, so that the output result can be submitted)

 

 

 

 

 

SVN version: 1.5 and later versions

Glossary:

WC: working copy your workspace

Versioned: controlled; version-controlled

 

What is SVN?

 

  • SVN is an open-source version control system.
  • More features than CVs. A better CVs? Therefore, SVN has many features of CVS.
  • Not only files are controlled, but directories are also added with version control.
  • Copying, deleting, and renaming are all controlled.
  • Special metadata (attributes ).
  • Submit the atomicity of the transaction. None of the parts will take effect until the submission is complete. The version number is based on submission, not on files. The log message at the time of submission is also dependent on the submitted version.
  • It is very easy to create branches and tags. You can use the copy command to create branches and tags.
  • Merge a trail. Assists you with all change points during the merge.
  • File lock. SVN supports file lock and modification policies.
  • UNIX links can be controlled. The premise is that wc must be in UNIX.
  • The optional Apache network server is based on the WebDAV/DeltaV protocol. Administrators familiar with Apache will like this very much.
  • Built-in server selection (svnserve ). If you do not want to use Apache, try SVN's own server: svnserve. It can also provide authorization and authentication, ssh channel, and other functions.
  • Easy to parse output. SVN output is as convenient as possible for reading and machine parsing.
  • Conflict resolution is highly interactive. The SVN command line client provides multiple methods to resolve conflicts.
  • SVN provides a utility, svnsync, to synchronize data from the master database to the read-only slave database.
  • The continuous write proxy feature allows read-only sub-databases to process all read requests. All write requests are sent to the master database for processing. This function is only valid when Apache WebDAV server is used.
  • Based on the localized client server system, hierarchical libraries, and clear APIs for easy scaling.
  • Efficient processing of binary files.
  • The performance consumption is proportional to the number of change points.
  • SVN APIs can be integrated with multiple languages. Python, Perl, Java, and Ruby (SVN itself is written in C)
  • The changelists function.

SVN installation is divided into clients and servers.

You can find the download at: http://subversion.tigris.org/

This article mainly describes the commands of the svn client. You must install the client at least. By default, SVN is used for version control. If you do not want to install the service version on your machine, Google Code is a good place to practice SVN commands.

Applying for managed projects on the http://code.google.com is simple, but SVN lock is not supported now. Currently, a maximum of 1 GB space is supported.

 

The following is a list of common commands on the svn client:

 

SVN add [path]

Alias: None

Description: adds a file or directory to your WC and marks it as a new one. These files will be submitted to the svn server next time you submit WC.

Before submission, you can also use SVN revert to cancel the new file.

Database Access: No

Eg: SVN add file. cpp

 

SVN blame target [@ rev]

Alias: praise, annotate, Ann

Description: displays the last modified version and author of each row of a controlled file.

Database Access: Yes

Eg: SVN blame file. cpp

Eg: SVN blame -- XML file. cpp # Add XML parameters to display the attributes of each row in XML format.

 

SVN cat target [@ rev]

Alias: None

Description: output the content of the specified target. The target here is generally a file.

Database Access: Yes

Eg: SVN cat file. cpp

Eg: SVN cat file. cpp-R 2 # displays the file. cpp content with version 2.

Eg: SVN cat file. cpp -- Revision head # displays the file. cpp content of the latest version.

 

SVN changelist clname target...

SVN changelist -- remove target

Alias: CL

Description: You can logically group the files in WC.

Database Access: No

Eg: SVN Cl clname file. cpp file2.cpp file3.cpp # Add file. cpp and other three files to the changelist named clname

Eg: SVN commit -- changelist clname-M "Ci" # submit all files under clname

 

SVN checkout URL [@ rev]... [path]

Alias: Co

Description: Check out.

Database Access: No

Eg: SVN checkout file: // var/SVN/repos/test file: // var/SVN/repos/quiz working-copies

Eg: SVN checkout-R 2 file: // var/SVN/repos/test mine # Check out a project whose version is 2

 

SVN cleanup [path...]

Alias: None

Description: recursively clears expired locks and unfinished operations in WC.

Database Access: No

Eg: SVN cleanup

 

SVN commit [path...]

Alias: Ci

Description: Submit your WC changes to the repository.

Database Access: Yes

Eg: SVN commit-M "added howto section." # by default, a log message is required for submission.

 

SVN copy SRC [@ rev]... DST

Alias: CP

Description: copy operations can be performed from WC to WC; WC to URL; URL to WC; URL to URL. Currently, SVN only supports copying files in the same repository and does not allow cross-repository operations.

Database Access: Yes

Eg: SVN copy-r 11 file: // var/SVN/repos/test/trunk \

File: // var/SVN/repos/test/tags/0.6.32-prerelease \

-M "forgot to tag at rev 11"

# The Copy command is a common method for creating branches and labels. The copy to URL operation implies the commit action, so log messages must be provided.

 

SVN Delete path...

Alias: del, remove, RM

Description: Delete.

Database Access: If path is the database address, files in WC will not be deleted.

Eg: SVN del localfile. cpp # delete the files in WC. The corresponding files will be deleted in the warehouse only after the WC is submitted.

Eg: SVN del file: // var/SVN/repos/test/Yourfile # delete files in the repository

 

SVN diff

Alias: Di

Description: used to compare and display the modification points.

Access database:

Eg: SVN diff # The most common method for displaying WC Based on all the local modification points after the last update.

Eg: SVN diff-r 301 bin # Compare the bin directory modification points in WC and version 301

Eg: SVN diff-r 3000: 3500 file: // var/SVN/repos/myproject/trunk # compare the differences between master 3000 and master 3500 in the library.

Eg: SVN diff -- summarize -- XML http://svn.red-bean.com/repos/?email protected] http://svn.red-bean.com/repos/test # -- summarize -- XML parameters display the differences as XML documents.

 

SVN export [-r rev] URL [@ pegrev] [path]

SVN export [-r rev] path1 [@ pegrev] [path2]

Alias: None

Description: exports a clean directory tree that does not contain all controlled information. You can choose to export from URL or WC.

Database Access: If the URL is accessed, it will.

Eg: SVN export file: // var/SVN/repos my-export # export to the my-export directory.

 

SVN help-help!

Alias :?, H

Description: No need to explain.

Database Access: No.

 

SVN import [path] URL

Alias: None

Description: import a local directory to the database. However, after the import, the local directory is not controlled.

Access Database: Yes.

Eg: SVN import-M "New Import" myproj http://svn.myProject.com/repos/trunk/misc

 

SVN info [target [@ rev]...]

Alias: None

Description: displays the specified WC and URL Information.

Database Access: only when the database path is accessed.

Eg: SVN info -- XML http://svn.myProject.com/repos/test # displays information in XML format.

 

SVN list [target [@ rev]...]

Alias: ls

Description: displays the list of objects and directories under the target.

Database Access: if the database address is accessed.

Eg: SVN list -- verbose file: // var/SVN/repos # -- verbose parameter indicates that detailed information is displayed.

 

SVN Lock target...

Alias: None

Description: gets the modification lock for the target. If the target has been locked by another user, a warning message is thrown. Use the -- force parameter to force a lock from another user.

Database Access: Yes

Eg: SVN lock -- force tree.jpg

 

SVN log [path]

SVN log URL [@ rev] [path...]

Alias: None

Description: displays log messages from the database. Log message code A: added D: deleted M: modified R: replaced

Database Access: Yes

Eg: SVN log-V http://svn.myProject.com/repos/test/ Foo. c bar. C # details the log information of all versions of foo. C and bar. C in the library of the specified URL.

Eg: SVN log-R # displays the log information of the 14 and 15 versions of the current WC.

For example: # If the version number is not continuous, use the following method.

$ SVN log-R 14> mylog

$ SVN log-R 19> mylog

$ SVN log-R 27> mylog

 

SVN merge sourceurl1 [@ n] sourceurl2 [@ M] [wcpath]

SVN merge [email protected] [email protected] [wcpath]

SVN merge [[-c m]... | [-R n: m]...] [source [@ rev] [wcpath]

Alias: None

Description: merges the differences between two controlled sources and stores them in a WC.

Database Access: only when the database address is accessed.

Eg: SVN merge -- reintegrate http://svn.example.com/repos/calc/branches/my-calc-branch # merge changes on the branch to WC, which is often used for Branch merge to the trunk.

Eg: SVN merge-r 156: 157 http://svn.example.com/repos/calc/branches/my-calc-branch # merge all updates from URL versions 156 to 157 to WC.

 

SVN mkdir path...

SVN mkdir URL...

Alias: None

Description: Creates a directory in the WC or library path.

Database Access: only when the database address is accessed.

Eg: SVN mkdir newdir

 

SVN move SRC... DST

Alias: MV, rename, Ren

Description: equivalent to the svn COPY Command and the svn DELETE command. Renaming WC to URL is not allowed.

Database Access: only when the database address is accessed.

Eg: SVN move foo. c bar. C # rename Foo. C to bar. C.

 

SVN propdel propname [path...]

SVN propdel propname -- revprop-r rev [target]

Alias: pdel, PD

Description: deletes a property from a controlled file or directory. The second is to delete the additional attributes of a specified version.

Database Access: only when the database address is accessed.

Eg: SVN propdel SVN: mime-type somefile # Remove the svn: mime-type attribute from somefile.

 

SVN propedit propname target...

SVN propedit propname -- revprop-r rev [target]

Alias: pedit, PE

Description: Edit attributes.

Database Access: only when the database address is accessed.

Eg: SVN propedit SVN: keywords file. C # modify the svn: keywords attribute on file. C.

 

SVN propget propname [target [@ rev]...]

SVN propget propname -- revprop-r rev [url]

Alias: pget, PG

Description: obtains the value of a specified attribute from a file, directory, or version.

Database Access: only when the database address is accessed.

Eg: SVN propget SVN: keywords file. C # obtain the svn: keywords attribute value from file. c

 

SVN proplist [target [@ rev]...]

SVN proplist -- revprop-r rev [target]

Alias: plist, pl

Description: used to list all additional attributes of a file, directory, or version.

Database Access: only when the database address is accessed.

Eg: SVN proplist -- verbose file. c

 

SVN propset propname [propval |-F valfile] path...

SVN propset propname -- revprop-r rev [propval |-F valfile] [target]

Alias: pset, PS

Description: attaches attributes to a file, directory, or version, and assigns values.

Database Access: only when the database address is accessed.

For example: SVN propset SVN: mime-type image/JPEG file.jpg: the object is attached to file.jpg with the svn: mime-type. The value is image/JPEG.

Eg: SVN propset -- revprop-R 25 SVN: log "journaled about trip to New York ."

# Add a log message to version 25

Eg: SVN propset SVN: Ignore '. classpath '.

# Ignore the. classpath file locally

 

SVN resolve path...

Alias: None

Description: Mark the conflicting files as resolved and delete the temporary files generated by the conflict. Note that this command does not resolve the conflict, but manual intervention is required to resolve the conflict.

Database Access: No

Eg: SVN resolve -- accept mine-full Foo. C #1.5, add the -- accept parameter, and try to automatically handle conflicts.

 

SVN resolved path...

Alias: None

Description: it is out of date and replaced by resolve -- accept. Remove conflicting statuses and temporary files.

Database Access: No

 

SVN revert path...

Alias: None

Description: restores all local changes in WC.

Database Access: No

Eg: SVN revert -- depth = infinity. # restore all files in the entire directory

 

SVN status [path...]

Alias: stat, St

Description: State of the files and directories in WC. If WC is submitted, these statuses will be synchronized to the library.

Generally, ''is not modified.

'New'

'D' Delete

Modify 'M'

'R' substitution

'C' conflict

'I' ignore

'? 'Uncontrolled

'! 'Loss, usually caused by direct deletion of controlled files

Database Access: When the -- show-Updates parameter is added

Eg: SVN status WC

 

SVN switch URL [@ pegrev] [path]

SVN switch -- relocate from to [path...]

Alias: SW

Description: Transfers WC to another database address for synchronization.

Database Access: Yes

Eg: svn sw http://svn.myProject.com/repos/trunk/vendors. # Switch the current WC to another URL

 

SVN unlock target...

Alias: None

Description: unlock.

Database Access: Yes

Eg: SVN unlock somefile

 

SVN update [path...]

Alias: Up

Description: Updates WC. There are several types of update feedback.

A new

B lock destruction

D. Delete

U update

C conflict

G merge

E

Database Access: Yes

Eg: SVN up-R22 # update to a specified version

 

PS: how to remove the user authorization password stored in SVN

Find the auth/SVN. Simple directory under the Subversion installation directory and delete the following files.

If you are in the turtle, you can set setting-> saved data-> authentication data point clear.

 

References: http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.checkout.html

 

 

 

SVN command line instructions
================================



0. View help

Command: SVN help



1. Synchronize (checkout) server data to local

Command: SVN checkout <URL> [Directory]
SVN Co <URL> [Directory]

Example: Synchronize the https://svn.test.cn/book/network/ directory to the local/usr/local/SVN/book/network directory

# Cd/usr/local/SVN/book
# SVN checkout https://svn.test.cn/book/network/
...
(R) eject, accept (t) emporarily or accept (p) ermanently? T
...
Password for 'wandering ': <press enter> # Wandering is the account of the current logon system.
Authentication realm: Username: Jack
Password for 'jack': <password>
...



2. Submit (COMMIT) Local documents to the server

Command: SVN commit-M "" [directory | file]
SVN ci-M "" [directory | file]

For example, submit/usr/local/SVN/book/Network/tcpip.txt to the server, provided that the file already exists on the server.

# Cd/usr/local/SVN/book/Network/
# SVN commit-M "" #-M indicates the recorded log information, which can be empty.

Generally, you only need to execute SVN ci-M "" in the directory where the data file to be updated is located.



3. Update Server data to local

Command: SVN update [directory | file]
SVN up [directory | file]

For example, update the content in the https://svn.test.cn/book/network/ directory to local

# Cd/usr/local/SVN/book/Network
# Cd update



4. View logs

Command: SVN log [directory | file]

For example, view the modification log of the/usr/local/SVN/book/network directory.

Method 1:

# Cd/usr/local/SVN/book/Network
# SVN log

Method 2:

# SVN log/usr/local/SVN/book/Network



5. add local data to the server

Command: SVN add <directory | File>

SVN command line basic operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.