How to use SVN under Linux

Source: Internet
Author: User
Tags diff svn update

1. checkout files to a local directory

svn checkout Path (path is a directory on the server)
For example: SVN checkout svn://192.168.1.1/Pro/Domain
Shorthand: SVN co

2 . Add a new file to the repository

SVN Addfile
Example: SVNAddtest.php (add test.php)
SVNAdd *. PHP (Add all the PHP files in the current directory)
Note: To submit the modified file to the repository, be aware of the difference from the SVN add feature, add is not committed to the server, but "scheduled to be submitted to the repository."
Therefore: The new file is scheduled to be added to the repository (it is not actually added to the repository), as long as the file is not in the repository and the file must be new. After SVN add, you must then use SVN ci to actually commit to the repository.


3 . Submit the changed files to the repository

SVN commit -M "logmessage"[-n] [--no-unlock] PATH (use--no-unlock switch if hold lock is selected)
Example: SVN commit-m "Add test file for my test" test.php
Shorthand: svn ci

4. Locking/unlock

SVN lock -M"Lockmessage"[--force]PATH
Example: SVN lock-m"Lock test File"test.php
svn unlock PATH

5. Update to a version


SVN up (SVN update) status abbreviation meaning:
A:add, add c:conflict, conflict d:delete, delete m:modify, Local has modified g:modify and merged, local file modification and merge with server u:update, update r:replace from server, Replace i:ignored from server, ignore



SVN update-r m path
For example:
SVN update If there is no directory behind it, the default is to update all files in the current directory and subdirectories to the latest version.
SVN update-r $test.php (Restore the file test.php in the repository to version 200)
SVN update test.php (updated, sync in Repository.) If the prompt expires at the time of submission, it is because of the conflict, you need to update, modify the file , then clear the SVN resolved, and then commit the commit)
Shorthand: SVN up

Note: A. Using SVN up means that files are synced from the server, synced to the latest version by default, and B. To differentiate between up and CI, up is to update the current project to a version of the repository, and CI is to update the current file or a directory to the repository, if there is a new file, you must first use the add re-ci;
C. SVN up will only update the new files on the server without changing the files that have been modified locally that have not yet been committed to the server.


Note: This approach can cause a problem: if you compile the kernel, This directory Dir1 generates some. o files and some other target files that cannot be submitted to the server, in which case there are two workarounds: one: Directly remove the generated. o files and unwanted files, and then svn add Dir1. The disadvantage of this approach is that it requires recompilation. Two: Do not delete the generated. o files and other files, first use the SVN add--depth=empty dir1 to add this directory, and do not add other files under the directory, and then svn ci dir1 submit this empty directory, and finally in this way: SVN Add./dir1/ Fie_a Add the other specified files under this directory, and then svn ci./dir1/fie_a, which avoids the need to submit unnecessary files. The disadvantage of this approach is that it is inconvenient to submit more files.

6. view file or directory status

1 svn status path (status of files and subdirectories under directory, normal status not shown)
"?: not in SVN control; M: Content modified; C: conflict; A: Scheduled to be added to Repository; K: Locked"
2) svn status-v path (shows file and subdirectory status)
The first column remains the same, the second column shows the work version number, and the third and fourth columns show the last modified version number and the modified person.
Note: The SVN status, SVN diff, and SVN revert three commands can be executed without a network, because SVN retains the original copy of the local version in. svn.
Shorthand: SVN St

7. Delete Files

svn delete path-m"Delete Test fle"
Example: SVN delete svn://192.168.1.1/pro/domain/test.php-m"Delete test file"
Or go directly to svn delete test.php and then svn ci-m ' delete test file ', which we recommend using this
Shorthand: SVN (del, remove, RM)

8. View Logs

SVN log path
For example: SVN log test.php shows all changes to this file, and its version number

9. View File Details

SVN Info path
Example: SVN info test.php

10. Compare Differences

svn diff Path (compares the modified file to the base version)
Example: SVN diff test.php
svn diff -R m:n Path (difference between version m and version N)
Example: SVN diff-r 200:201 test.php
Shorthand: SVN di

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

svn merge-r m:n Path
Example: SVN merge-r $:205test.php (The difference between version 200 and 205 is merged into the current file, but there is a general conflict that needs to be addressed)

12. SVN Help

SVN Help
SVN help CI then c-x (C) Continue, it can be uploaded to the server.

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

The above is a common command, the following write a few common

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

13 . List of files and directories under the repository

SVN list path
Displays all files and directories belonging to the repository under the path directory
Shorthand: SVN ls

14 . Create a new directory under version control

svn mkdir: Create a new directory under the included version control.
Usage: 1, mkdir PATH ...
2. mkdir URL ...
Create a version-controlled directory.
1. Each directory specified in the working copy PATH will be created on the local side and added
Scheduled to be submitted for the next time.
2. Each directory specified in the URL will be created by submitting it to the repository immediately.
In both cases, all intermediate directories must exist beforehand.

15. Restore Local modifications

svn revert: Restores the original unchanged working copy file (restores most of the local modifications). Revert
Usage: revert PATH ...
Note: The notebook command will not access the network and will release the conflicting condition. But it won't recover.
Directories that were deleted


This article is referenced in the literature: http://blog.chinaunix.net/uid-22150747-id-189264.html

http://zhu-apollo-163-com.iteye.com/blog/1247216



How to use SVN under Linux

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.