Installation of SVN version management system under ubuntu14.04 and the use of common commands

Source: Internet
Author: User
Tags svn svn update perl script

Install SVN under ubuntu14.04
$sudo Apt-get Install Subversion
Perform this step on the installation is complete, in Ubuntu first installation is very convenient

After the installation is complete, create the repository directory, because it is the local environment, in a directory, if the real environment is equivalent to the directory on the server, because of the local, it is a server to simulate a repository

$sudo mkdir-p/OPT/SUBVERDION/SVN # # #创建版本库目录
$sudo svnadmin CREATE/OPT/SUBVERSION/SVN # # #创建版本库, generating the configuration file

Configure SVN, the configuration files are all in/OPT/SUBVERSION/SVN

1). Configure the user first
$sudo vim/opt/subversion/svn/conf/passwd

Add Format: User name = password
such as: XC = xc123

2). Configure permissions and groupings

$sudo Vim/opt/subversion/svn/conf/authz

[Groups] # # #分配组, no spaces at the beginning of the line
team1 = zhangsan,lisi # # #在组1中有zhangsan和lisi
team2 = Wangwu # # #在组2中只有wangwu

[svn:/] # # #分配权限,
Zhangsan = RW
@team1 = rw # # #在组名前需要加上 @ sign, do not need to add the @ symbol before the user, members in the TEAM1 group have ' Read and write ' permissions
@team2 = r # # #在team2组中的成员有 ' read ' permission
* = # # #其他用户没有任何权限

3). Configure the svnserve.conf file in the/opt/subversion/svn/conf directory to remove comments
$sudo vim/opt/subversion/svn/conf

Anon-access = none # # #将以前的read改成none
auth-access = Write
Password-db = passwd # # #
Authz-db = Authz

4). Turn on SVN service
$sudo svnserve-d-r/opt/subversion
-D: Specifies that the program runs in the background
-r: Specifies the SVN service directory, which is the repository directory
--listen-port Port: Set port, default is 3690

5). Verify that the success is turned on
$ sudo netstat-anp | grep svnserve
Returns the following information
TCP 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 18253/svnserve

6). How to turn off Svnserve
$sudo Pstree | grep svn #查看

$sudo Killall Svnserve #关闭


##############
The above six steps are equivalent to the settings on the server
When you are finished, do the following
##############

Set up a local directory in the home directory (relative to the server)

$mkdir-P Workspace/project

$CD/workspace/project

$sudo svn checkout svn://127.0.0.1/svn #和服务器上建立关联, the SVN directory is the SVN directory under/opt/subversion/
After entering the above command, a tab will pop up under ubuntu14.04, let you fill in the password user name of the thing, you can look at the fill on it

Then in the Workspace/project directory

$ll-A can see that there is a hidden folder. SVN, this directory is recorded by the user's various actions

##############
After the above steps, the SVN configuration is basically complete, then the SVN command can be manipulated.

The sudo update can be updated to see if the server's files are synchronized to the local no, you can see the SVN directory appears

* * Note: When using the SVN command under Ubuntu, sudo is generally performed
##############


/**************** First Error ***************************/
[Email protected]:~/workspace/project01$ svn add AAA
svn:e155004: Run "svn cleanup" delete lock (run "svn help Cleanup" for details)
svn:e155004: Working copy "/home/xc/workspace/project01" is locked
SVN:E200031:SQLITE[S8]: Attempt to write a readonly database
svn:e200031: Additional error:
SVN:E200031:SQLITE[S8]: Attempt to write a readonly database
******************/
The above should be used to log in as root, so that ordinary users will report the above error

/**************** a second error ***************************/

When svn:e155007 appears: "/opt/subversion" is not a working copy, this is because when configuring Authz permissions
[Groups]
team1 = Xc,lisi
TEAM2 = Lisi

[proj01:/] ##### #在这里冒号和/no spaces between
XC = RW

@team1 = RW
@team2 = R
* =

Recently often use SVN for code management, these commands always can't remember, have to go online to check, finally found a Linux under the SVN command use Daquan:

1. Checkout files to a local directory
SVN checkout Path (path is a directory on the server)
Example: SVN checkout Svn://192.168.1.1/pro/domain
Shorthand: SVN Co

2. Add a new file to the repository
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 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 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

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 (show 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
For example: SVN merge-r 200:205 test.php (the difference between version 200 and 205 is merged into the current file, but generally conflicts occur and need to be addressed)

12. SVN Help
SVN help
SVN help CI
——————————————————————————

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


16. Code Base URL Change
SVN switch (SW): Updates the working copy to a different URL.
Usage: 1, switch URL [PATH]
2. Switch–relocate from to [PATH ...]

1, update your working copy, map to a new URL, its behavior is similar to "SVN update", will also
The files on the server are merged with the local files. This is the one where the working copy corresponds to a branch or tag in the same warehouse.
Method.
2, rewrite the working copy of the URL metadata to reflect the simple URL changes. When the root URL of the warehouse changes
(such as scheme 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 correspondence between the working copy and the warehouse.
My example: SVN switch--relocate http://59.41.99.254/mytt Http://www.mysvn.com/mytt

17. Conflict Resolution
SVN resolved: Removes the "conflicting" status of the working Copy's directory or file.
Usage: Resolved PATH ...
Note: The book command does not resolve the conflict by syntax or remove the conflict token; it simply removes the conflicting
File, and then allow PATH to submit again.

18. Output the contents of the specified file or URL.
SVN cat Target [@ VERSION] ... If a version is specified, the lookup starts 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 can be submitted)

19. Find all the remaining log files in the working copy, delete the locks in the process .

When subversion changes your working copy (or any information in. svn), it will be as careful as possible, before modifying anything, it writes the intent to the log file, executes the command in the log file, and then deletes the log file, similar to the file system schema of the ledger. If subversion is interrupted (for example: The process is killed, the machine is dead), the log file is saved on the hard disk, and by re-executing the log file, subversion can complete the last operation, and your working copy can return to a consistent state.

This is what svn cleanup does: It looks for all the remaining log files in the working copy and deletes the locks in the process. If subversion tells you that a part of your work copy is "locked", you need to run the command. Similarly,SVN status will use L to display locked items:

$ SVN status
L Somedir
M SOMEDIR/FOO.C

$ svn cleanup
$ SVN status
M SOMEDIR/FOO.C

20. copy a user's non-versioned directory tree to the repository.

The SVN import command is the quickest way to copy a user's non-versioned directory tree to the repository and, if necessary, to create some intermediary files.

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

In the previous example, the directory Mytree will be copied to the repository some/project:

$ svn list file:///usr/local/svn/newrepos/some/project bar.c foo.c subdir/

Note that after the import, the original directory tree has not been converted into a working copy, in order to get started, you still need to run svn checkout to export a working copy.

Additional: Add an email notification to SVN
The ability to add a mailing list to SVN via the Subversion hook script
After compiling and installing subversion, there is a comm-email.pl perl script under Source Tools, and in your file directory there is a hooks directory that goes into the hooks directory to Post-commit.tmpl Rename to Post-commit and give it permission to execute.
Change the Post-commit script to add the comm-email.pl script to the path, otherwise SVN cannot find comm-email.pl

Repos= "$"
rev= "$"
/usr/local/svn/resp/commit-email.pl "$REPOS" "$REV" [email protected] [email protected]
#log-commit.py--repository "$REPOS"--revision "$REV"

The last line is for the log. I didn't use this function, so I commented out.

Installation of SVN version management system under ubuntu14.04 and the use of common commands

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.