LINUX-SVN Command __linux

Source: Internet
Author: User
Tags diff parent directory subversion client svn svn update

Http:// Not collated reference articles 1,SVN introduction

SVN (Subversion) is a free, open source version of the project source Code control tool. At present, most open source software and enterprise code management, using SVN as a code version management software. SVN stores the files in the central repository, which is much like a regular file server. The difference is that it can record every file and directory modification so that you can revert the data to a previous version when needed, and view the details of the changes to the data.

Because your work copy "doesn't make any difference to the files and directories on your system," You can change the file at will, but you have to tell subversion about anything else you do. For example, if you want to copy or move a working copy of a file, you should use SVN copy or SVN move instead of using the operating system's copy Movement command.

. SVN directory contains what. any one of the directories in the working copy includes an. SVN admin area, which usually does not display this directory, but it is still a very important directory, no matter what you do. Don't delete or change anything in this admin area, Subversion uses it to manage working copies. If you accidentally delete subdirectories. SVN, the easiest solution is to delete the included directory (normal file system deletion instead of SVN delete), and then run the SVN update,subversion client in the parent directory to download the directory you deleted and include the new. SVN.

2,svn Common Command 2.1, SVN Co: Checkout files to local directory

SVN checkout Path

Shorthand: SVN Co path

Description: Path is a directory on the server

For example: SVN co svn:// 2.2, SVN add: Adding new files to the version library

SVN Add File

Note: You cannot use the SVN add * command directly, you must use the SVN add *--force command. The--force parameter simply drives SVN to check a subdirectory, regardless of whether the subdirectory has been managed.

For example: SVN add *.php (Add all php files under current directory) 2.3, svn ci: Submitting changed files to the version library

SVN commit-m "LogMessage" [-n] [--no-unlock] PATH (use the –no-unlock switch if you choose to keep the lock)

Shorthand: SVN ci-m ' For example: SVN ci-m "Add test file for my test" test.php
2.4. SVN Lock: Lock/unlock svn lock-m "Lockmessage" [--force] PATH

SVN unlock PATH

For example: SVN lock-m "lock test File" test.php 2.5, SVN up: Update to a version

SVN update-r m path

Shorthand: SVN up

Description: SVN update if no directories are followed, the current directory and all files under the subdirectory are updated to the latest version by default.

For example: SVN up-r test.php (restores file test.php in the version library to version 200)

Select: (p) postpone, (DF) Diff-full, (e) Edit, (MC) Mine-conflict, (TC) theirs-conflict, (s) Show all opt

IONS:SVN detects that theres a conflict the here and require your to take some of action. (e) Edit-change merged file in a editor #直接进入编辑 (DF) diff-full-show all changes mad E to merged file #显示更改至目标文件的所有变化 (R) resolved-accept merged version of file (DC) display-conflict-s    How to all conflicts (ignoring merged version) #显示所有冲突 (MC) mine-conflict-accept I version for all conflicts (same) #冲突以本地为准 (TC) theirs-conflict-accept their version for all conflicts (same) #冲突以服务器为准 (MF) mine-full-accept    My version of entire file (even non-conflicts) #完全以本地为准 (TF) theirs-full-accept their version of entire file (same) #完全以服务器为准 (p) postpone-mark the conflict to be resolved later #标记冲突, resolved later (L) Launch-lau   Nch External Tool to resolve conflict (s) Show all      -Show This list 

Examples are as follows:

1, create Test.txt

2, upload the file, version for Revision3
C:\WORKSPACE\TEST>SVN Ci-m "Making a starting point"
sending        .
Sending        test.txt
transmitting file data.
Committed revision 2.
3, let's say we have User1 and User2. Both are downloaded from the Repository update file, the version is Revision2
C:\workspace\test>svn up
A    test.txt at
Revision 2.
4,user1 Modify File Test.txt
User1 is making a conflict test
5,user1 upload file Test.txt version for Revision3
C:\WORKSPACE\TEST>SVN ci-m "User1 Starting a conflict"
sending        .
Sending        test.txt
transmitting file data.
Committed Revision 3.
6,user2 Modify File Test.txt
Test User2 making a conflict
7,user2 upload file Test.txt, version of Revision4, encountered errors
Svn:commit failed (Details follow):
svn:file or directory ' Test.txt ' are out of date; try updating
Svn:resource Out of date; Try Updating
8,user2 Start updating files
Conflict discovered in ' Test.txt '.
Select: (p) postpone, (DF) Diff-full, (e) Edit,
        (MC) Mine-conflict, (TC) theirs-conflict,
        (s) Show All Options:
  SVN detects that theres a conflict the here and require your to take some of action.
9,user2 select ' DF ' to expand conflicting content
Select: (p) postpone, (DF) Diff-full, (e) Edit,
        (MC) Mine-conflict, (TC) theirs-conflict,
        (s) Show All OPTIONS:DF
---. Svn/text-base/test.txt.svn-base    Tue Aug 10:59:38 +++ svn/tmp/test.txt.2.tmp Tue-Aug 11:33:24
-1 +1,3 @@ @@ \
No NewLine at end of file
+<<<<<<<. Mine +test User2 making conflict=======-is +user1 a conf Lict test>>>>>>>. R3
10,user2 select ' E ' to edit conflicting content
<<<<<<< mine test User2 making conflict======= User1 is making a conflict test>>>>>& Gt;>. R3
11,user2 edits the conflict and saves it as follows:
User1 is making a conflict test User2 making conflict
12,user2 Select ' R ' to indicate resolved and be marked as g (indicates that the file conflict has been resolved)
Select: (p) postpone, (DF) Diff-full, (e) Edit, (R) resolved,
        (MC) Mine-conflict, (TC) theirs-conflict,
        (s) show a ll options:e
Select: (p) postpone, (DF) Diff-full, (e) Edit, (R) resolved,
        (MC) Mine-conflict, (TC) Theirs-confli CT,
        (s) Show all options:r
G    test.txt
Updated to Revision 3.
13,user2 Check the file status
C:\workspace\test2>svn St
M       test.txt
14,user2 submits the file, the version is Revision4
C:\WORKSPACE\TEST2>SVN ci-m "conflict resolved" sending Test.txt
file data.
Committed Revision 4.
15,user2 could have just chosen ' p ' to delay resolution of the conflict.
Select: (p) postpone, (DF) Diff-full, (e) Edit, (R) resolved,
        (MC) Mine-conflict, (TC) theirs-conflict,
        (s) show a ll options:p
C    test.txt
Updated to revision 3.
Summary of conflicts:
  Text conflicts:1
16, you will find SVN help to create the following three files
08/10/2010  11:44 am                test.txt
08/10/2010  11:44 AM test.txt.mine
08/10/2010  11:44 am                test.txt.r2
08/10/2010  11:44 AM                -Test.txt.r3
test.txt is a file that contains User1 and User2 conflicts
<<<<<<< Mine test User2 making conflict======= User1 am making a conflict test>>>> ;>>>. R3
Test.txt.mine is a User2 local file.
Test User2 making conflict
TEST.TXT.R2 is a copy of the original Reversion2
Copy of Reversion3 submitted by TEST.TXT.R3 for User1
User1 is making a conflict test
17, at this time User2 modified the Test.txt conflict and submitted
C:\WORKSPACE\TEST>SVN Resolve--accept working test.txt resolved conflicted state of
' Test.txt '
c:\ WORKSPACE\TEST>SVN ci-m "conflict resolved" sending Test.txt
file data.
Committed Revision 4.

2.6. SVN st: View file or directory status

1 SVN status Path (the state of the files and subdirectories under the directory, not shown in the normal state)

Description: "?: Not in the control of SVN; M: Content modified; C: conflict; A: scheduled to join repository; K: Locked

2 svn status-v path (displaying file and subdirectory status)

Note: The first column remains the same, the second column displays the working version number, and the third and fourth columns display the last modified version number and the modified person. 】

Shorthand: SVN St

Note: SVN status, SVN diff, and SVN revert these three commands can also be performed without a network, because SVN is local. SVN retains the original copy of the local version.
For example: SVN st-q (only display local modification entry information)

The status code that SVN status may return
A file, directory, or symbol chain item is scheduled to be added to the version library.
File item conflicts, when updated from the server with the local version overlap, before you submit to the repository, you must manually resolve the conflict.
The file, directory, or symbol chain item is scheduled to be deleted from the version library.
The contents of the file item have been modified.
A file, directory, or symbolic chain item is scheduled to replace the item in the version library, which means that the object is to be deleted first, and that another object with the same name will be added, all of which occur in a revised version.
The directory is not versioned, but is associated with Subversion's external definition, and for external definitions, see the "External definition" section.
File, directory, or symbol chain item is not under version control, you can ignore this problem by using the--quiet (-q) parameter of SVN status or the Svn:ignore attribute of the parent directory.
The file, directory, or symbol chain item is under version control, but has been lost or incomplete, possibly because of a non-Subversion command deletion, if it is a directory that might have been caused by an outage or an update, using SVN Update can get files or directories from the version library, or use svn revert file to recover the original files.
The file, directory, or symbol chain item already exists in the version library, but your work copy is another one. For example, you delete a version of a library file, create a new one in the original location, and do not use SVN delete or SVN add throughout the process.
The file, directory, or symbol chain item is not under version control, and subversion is configured to ignore the file in the SVN Add, SVN import, and SVN status commands. Note that this symbol only appears when using the parameters of SVN status--no-ignore-otherwise the file will be ignored and not displayed.

2.7, svn del: Delete Files

SVN delete path-m "Delete test Fle"

Shorthand: SVN (del, remove, RM)

For example: First, svn delete test.php again, svn ci-m ' delete test file '
2.8, SVN log: View Log

SVN log path

For example: SVN log-l 3 test.php shows the last three changes to this file, and its version number

For example: SVN log file-r 204424 shows r204424 for this version of submit information

For example: SVN log file-r 204424-v details r204424 This version of the submission record

2.9, SVN info: View file details

SVN info path For example: SVN info test.php

2.10, svn diff: Compare differences

1 svn diff path (compares the modified file to the base version)

For example: SVN diff test.php

2 svn diff-r m:n Path (diff for version M and version N)

For example: SVN diff-r 200:201 test.php

For example: SVN diff-c r208425 View this version of the difference shorthand: SVN di

root@letuknowit:/home/kris/calc/trunk# svn diff main.c
===================================== ==============================
---main.c      (revision 8)
+++ MAIN.C      (Working copy
) @@ -7,7 +7,8 @@
        printf ("5 + =%d.\n", add (5,10));
        printf ("15-10 =%d.\n", sub (15,10));
        Kris ' s test
-       printf ("Kris:12 + =%d.\n", add (12,28));
+       printf ("kris:32 + =%d.\n", add (32,28));
+       printf ("kris:15-10 =%d.\n", sub (15,10));
        Sally ' s test
        printf ("sally:60-33 =%d.\n", sub (60,33));
        return 0;
SVN diff can view all the modified files in the current working copy, and the diff output portion of each file is distinguished by the form of the index: file name. The content after the equals number is the diff for the main.c file.
---main.c      (revision 8)
+++ MAIN.C      (working copy)
---starts with the original file, the latest version in the version library, or the file before the modification
+++ is the target file, and this is your revised version.
@@ -7,7 +7,8 @@
Here-and + to represent the original and target files, 7,7 represents 7 lines starting at line 7th, -7,7 is the original file from the 7th line of 7 lines, +7,8 meaning similar, representing the target file from the 7th line of 8 rows.

In combination, there is a difference between the 8 lines starting at line 7th and the 7 lines of the original file starting at line 7th.

        printf ("5 + =%d.\n", add (5,10));
        printf ("15-10 =%d.\n", sub (15,10));
        Kris ' s test
-       printf ("Kris:12 + =%d.\n", add (12,28));
+       printf ("kris:32 + =%d.\n", add (32,28));
+       printf ("kris:15-10 =%d.\n", sub (15,10));
        Sally ' s test
        printf ("sally:60-33 =%d.\n", sub (60,33));
        return 0;
That's the exact difference. The preceding-number indicates the line that needs to be deleted from the original file, and the + number indicates the row to be added in the target file, and the first part of the number belongs only to the original file, and the first part of the + number belongs only to the target file, and the rest is the same part.
  7   1   1         printf ("5 + =%d.\n", add (5,10));
  8   2   2         printf ("15-10 =%d.\n", sub (15,10));
  9   3   3         //kris ' s test   4     -       printf ("Kris:12 + =%d.\n", add (12,28));
 One       4 +       printf ("kris:32 + =%d.\n", add (32,28));       5 +       printf ("kris:15-10 =%d.\n", sub (15,10));   5   6         //sally ' s test   6   7         printf ("sally:60-33 =%d.\n", sub (60,33));   7   8 return         0;
To further understand the meaning of the @@ -7,7 +7,8 @@ -7,7 with the line number and other information, the number in the first column is the line number, and the number in the following two column indicates the row. The callout can clearly see the original file line 7th start of the 7 lines and the target file line 7th began 8 lines of content.

2.11. SVN Merge: Merge the differences between the two versions into the current file

SVN merge-r m:n path for example: SVN merge-r 200:205 test.php (merging the differences between version 200 and 205 into the current file, but there is a general conflict that needs to be addressed)

2.12. SVN help: Helping SVN helps

SVN help CI

2.13, svn mkdir: Create a new directory svn mkdir

Description: Creates a new directory under version control.

2.14, svn revert: Restore local modifications svn revert PATH

Description: Mainly used to restore the SVN state of the file, such as an SVN file is a (add), D (delete), M (Modify) state, then use SVN revert can restore the file to the original "SVN state."

2.15, SVN resolved: Conflict resolution SVN resolved PATH

Description: Removes the conflicting state of the directory or file for the working copy.
Note: The notebook command does not resolve the conflict by syntax or removes the conflict token; it simply removes the associated file for the conflict and then lets the PATH be resubmitted.

2.16. SVN import: Import Using SVN import is a quick way to copy an versioned file tree to a database, and it needs to create a temporary directory.

$ svnadmin create/usr/local/svn/newrepos
$ svn import mytree file:///usr/local/svn/newrepos/some/project
Adding         mytree/foo.c
adding         mytree/bar.c
adding         mytree/subdir Adding mytree/ Subdir/quux.h

committed Revision 1.
The above example copies the contents of the Mytree directory in the Some/project directory to the repository.
$ svn list file:///usr/local/svn/newrepos/some/project

Note that after the import is complete, the original tree is not converted to a working copy. To get started, you still need SVN to checkout a new working copy of the tree. 2.17 SVN diff--summarize: Branch diff Package

On a branch, it's your code, you need to finalize the line, you can just find the diff before you pack it.

SVN diff--summarize-r37565:37571 | awk ' {print $} ' | Xargs tar czvf 	backup_$ (date +%f). tar.gz
TAR-CZVF test_diff.tar.gz ' svn di--summarize-r41413:41408| awk ' {print $} '

Note that when looking for the original version and the latest version, SVN log defaults to the current directory log record. is not necessarily the latest log of the entire code tree. Therefore, it is recommended to use a URL to find.

SVN Log https://develop/genericbranch_7 | Less

2.18 Creating a new branch

SVN cp-m "Create new branch" Http://online-r 38577 http://branch_7

3,SVN General Log Flow Update code: SVN up View log: SVN log
View specific modification information: SVN diff-c r208425
SVN restore specific version: SVN revert-r 208425
4, the typical work cycle is this: update your working copy
SVN update
Make changes
SVN add
SVN delete
SVN copy
SVN move
Inspection modification
SVN status
SVN diff
Some modifications may be canceled
svn revert
Resolve Conflicts (Merge others ' changes)
SVN update
SVN resolved
Submit your changes
SVN commit
5,svn List of common commands

Command function Use Format
Checkout Check out SVN Co URL
up Update to the end of the current URL SVN up
Switch Update to a Tag/branch SVN switch (tag/branch) URL
Add Increase svn add filename/directory name
RM deleting files SVN rm filename
Delete Directory SVN RM Directory Name
diff Compared to the base version (last checked out or updated to version) SVN diff
Compare to the latest version in the version library SVN diff-r Head
Current working copy, comparison between two versions SVN diff-r Reversion1:reversion2
Any two tags in the version library are compared SVN diff (tag1) url (tag2) URL
ci Submit SVN ci-m "Commit log"
Log View current Working copy log SVN log
View only the specified version of log SVN log-r
Print log all additional information SVN log-v
View current Tag/branch version details SVN log--stop-on-copy-v
Info View the URL of the current working copy SVN info
Status View the status of a working copy SVN St
To view the taglist of a file SVN command not supported, can perform CS taglist
Tag Add tag svn cp. (tag) URL
Delete tag SVN rm (TAG) url-m "Commit Log"
Overwrite the already existing tag does not support
Branch Development Create Branch SVN CP (Baseline version) URL (branch) url-m "Commit Log"
Delete Branch SVN rm (branch) url-m "Commit Log"
Synchronous SVN Co (backbone) URL
svn merge (trunk) URL (to be synchronized tag) URL
svn ci-m "commit log"
svn cp (Backbone) URL (tag at end of _pd_bl_main) url-m "Commit log"
Merge SVN Co (merge target) URL
svn merge (baseline version tag) URL (online tag)
svn ci-m "commit log"
svn cp (merge target) URL (tag corresponding to line Tag_merge_) url-m "Commit log"

Related Article

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: 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.