Version Control-svn server setup and Common commands (centos 6.3),-svncentos
Svn is an excellent version control tool. Although its functions and performance cannot be comparable to that of Git, it is still very popular in small companies because it is easy to build and use. For details about how to use Git, refer to Version Control-Git server setup and common command usage. This article introduces how to build svn servers and Common commands.
Server Construction
Local Server
Http Server
Command
Common commands
Uncommon commands
[root@master data1]# cat /etc/issueCentOS release 6.3 (Final)Kernel \r on an \m[root@master data1]# getconf LONG_BIT64
1. Create a local svn Server
1. Install the svn Server
[root@master data1]# yum install subversion -y
2. Create the svn Server Directory and initialize the first warehouse project
mkdir /data1/svnsvnadmin create /data1/svn/project
3. Create a folder and import it to the server as the first folder of the Svn repository project.
cd /data1mkdir -p test/client test/serversvn import test file:///data1/svn/project/ -m 'init svn project'rm -rf test
In this way, the client and server folders under the test directory are imported to the warehouse project, and the test folder is deleted.
4. Add a user and set a password
Modify the file/data1/svn/project/conf/passwd to add users lx, u1, u2, and u3. The corresponding plaintext password is on the right of "="
[users]# harry = harryssecret# sally = sallyssecretlx = lx_passwdu1 = u1_passwdu2 = u2_passwdu3 = u3_passwd
5. Add groups and add Access Control
Modify the file/data1/svn/project/conf/authz, add g_lx and g_user groups, and set access control permissions for the project repository. Different directories allow different groups to perform different operations.
[groups]g_lx = lxg_user = u1, u2, u3[project:/]@g_lx = rw* =[project:/server]@g_lx = rw@g_user = r* =[project:/client]@g_lx = rw@g_user = rw* =
R indicates that the directory has read permission, w indicates that the directory has write permission, and rw indicates that the directory has read and write permissions. * = In the last row indicates that no one except the user group with the preceding permissions is allowed to access this directory. This is important.
6. modify the configuration file
Modify the file/data1/svn/project/conf/svnserve. conf to read the correct configuration.
[general]anon-access = Noneauth-access = writepassword-db = /data1/svn/project/conf/passwdauthz-db = /data1/svn/project/conf/authz
The anon-access control does not allow the user to access the version library. The value range is write, read, and none. The default value is read.
Auth-access controls the permissions of registered users to access the version library. The value range is write, read, and none. The default value is write.
Password-db specifies the username and password file name. If there is no absolute path, the file location is the relative path of the conf directory.
Authz-db specifies the permission configuration file name, which can be used to implement path-based access control. If there is no absolute path, the file location is the relative path of the conf directory.
Realm specifies the authentication domain name of the version library.
7. Start the Svn local server
svnserve -d -r /data1/svn/ps -ef | grep svnnetstat -anp | grep svn
8. check out on other machines
svn co svn://master/projectUsername: lxPassword for 'lx':
The master is the domain name. You are advised to use the IP address directly.
What if I encounter Store password unencrypted (yes/no )? Enter yes
Password for 'root': Press enter and enter the user name lx and Password.
Test submission command
cd project/cd client/touch client.shsvn add client.shsvn ci -m 'add client.sh'
Ii. Upgrade to an http Authentication Server
Generally, the company's Svn server will be built into an https-authenticated server, and the password will use ldap authentication. Therefore, it is troublesome to build the server. In addition to httpd, we also need open-ssl and Other plug-ins to support it, but it is safe and practical. This document only describes common http Authentication and uses a local password for verification.
1. Install relevant software to upgrade http
yum install subversion mysql-server httpd mod_dav_svn sendmail wget gcc-c++ make unzip -y
2. http supports encrypted passwords. Therefore, you need to convert the svn plaintext password.
touch webpasswdhtpasswd -b webpasswd lx lx_passwd
Step by step conversion or create the following perl script pd. pl in the/data1/svn/project/conf directory
#!/usr/bin/perluse warnings;use strict;open (FILE, "passwd") or die ("Cannot open the passwd file!\n");open (OUT_FILE, ">webpasswd") or die ("Cannot open the webpasswd file!\n");close (OUT_FILE);foreach (<FILE>) { if($_ =~ m/^[^#].*=/) { $_ =~ s/=//; `htpasswd -b webpasswd $_`; }}
Run perl pd. pl output: Adding password for user lxAdding password for user u1Adding password for user u2Adding password for user u3
3. Modify the httpd. conf file
Vim/etc/httpd/conf/httpd. add <Location/project> DAV svn SVNPath/data1/svn/project/AuthType Basic AuthName "svn for project" AuthUserFile/data1/svn/project/conf/webpasswd AuthzSVNAccessFile at the end of the file /data1/svn/project/conf/authz Satisfy all Require valid-user </Location>
4. Change the folder owner to apache
chown -R apache.apache /data1/svn/project/
Ps aux | grep httpd can be seen in apacheapache 26834 0.0 0.0 281608 3788? S/usr/sbin/httpd-DFOREGROUNDapache 26835 0.0 0.0 281840 5072? S/usr/sbin/httpd-DFOREGROUNDapache 26836 0.0 0.0 298372 6644? S/usr/sbin/httpd-DFOREGROUNDapache 26837 0.0 0.0 298372 6644? S/usr/sbin/httpd-DFOREGROUNDapache 26838 0.0 0.0 281680 4816? S/usr/sbin/httpd-DFOREGROUNDapache 26839 0.0 0.0 298360 6512? S/usr/sbin/httpd-DFOREGROUNDapache 26854 0.0 0.0 281680 4812? S/usr/sbin/httpd-DFOREGROUND
5. Restart httpd
service restart httpd
6. Open the web page http: // master/project/
We recommend that you change to an IP address. Enter the account password as follows:
Iii. Common svn commands
1. checkout to the local directory
svn -–username=*** --password=*** checkout path
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 you choose to keep the lock, use the-no-unlock switch #-m is followed by the submitted log information, which is generally required.
Abbreviation: svn ci
4. Lock/unlock
svn lock -m "LockMessage" [--force] PATH
5. Update to a local version.
Svn update-r * path # * is the svn update # svn update file of the entire folder # a separate file
6. view the file or directory status
1) svn status path # The status of the files and subdirectories under the directory. The normal status does not show 【? : 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 # the first column of the file and subdirectory status is the same, the second column shows 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: // master/project/test. php-m "delete test file" or step-by-step (recommended) svn delete test. phpsvn ci-m'delete test file' Abbreviation: svn [del, remove, rm]
8. View logs
Svn log file displays all the modification records and version changes of this file.
9. View File details
svn info file
10. Differences
Svn diff path # Compare the modified file with the basic version, for example, svn diff test. phpsvn diff-r m: n path # comparison of version m and version n, for 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 200:205 test. php # merge the differences between version 200 and version 205 to the current file, but there are usually conflicts. You need to manually modify the file
12. Svn help
svn helpsvn help ci
The above are common commands. Below are a few
13. List of files and directories in the version Library
Svn list path # display 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... Create a version control directory.
(1) Each directory specified by the working copy PATH will be created on the local end and added to the new scheduling for the next submission. (2) Each directory specified by URL is created by submitting it to the repository immediately. In both cases, all the intermediate directories must exist in advance.
15. Restore local modification
Svn revert: restore the original unchanged working copy file (recover most local modifications ). Usage: revert PATH... Note: The sub-commands do not access the network and will release the conflict. However, it does not restore the 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 working copy and map it to a new URL. The behavior is similar to "svn update", and the files on the server are merged with local files. This is a method that maps a work copy to a branch or tag in the same repository. (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 changes ), however, when the working copy is still mapped to the same directory in the same warehouse, use this command to update 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 files and then allow the PATH to be submitted again.
18. output the content of the specified file or URL
Svn cat target [@ version]… If a version is specified, search for it 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)
The content in this article is based on online resources, which are organized by the blogger @ Lx.
Original article, reprinted please note the original address http://www.cnblogs.com/lxmhhy/p/6044054.html
Add qq: 1130010617 for knowledge exchange and discussion. Thank you for your cooperation.