Use SVN sync code on linux Server CentOS to project

Source: Internet
Author: User



I. Requirements



1. The management of Code and versioning in the multi-person development process is an important issue, as we may be able to make a file or make more files in the process of development.



This can cause us to be prone to errors. So we need a way to manage our code.



Two. Solution



1. Using SVN to manage code



2. Managing code with Git



The differences between the two methods of code management I read this article written in very detailed http://blog.csdn.net/jackjia2015/article/details/50607408, interested can see, here is not



Talk about their differences, after all, this article is about how to use the SVN synchronization code into the project






Three. Detailed procedures


    1. Install SVN server side
      Yum Install Subversion   

      Just follow the prompts ok down the line, no other problems, after the installation of the SVN directory created

    2. Create SVN directory
      mkdir / home / svn // Create svn folder in the home directory
      
      svnadmin create / home / svn / test // Create svn version repository test 

      After creation, in the SVN directory you will see the test directory, the test directory details as follows


      Here is a detailed explanation of these directories

      In this article is mainly to configure the SVN information and how to synchronize the code, so the directory involved only conf directory and hooks directory, below, we began to explain how to configure SVN


3. Configure SVN's basic information


    1. CD./conf // Enter the configuration folder


  
Authz files are permissions to create SVN group and group users
passwd setting the user's account number and password in the group
svnserve.conf Configuring the Repository information and the path to the user and user password files, the repository path
(if multiple warehouses are controlled by the same permissions, account and password, the authz,passwd file can be placed in the SVN directory)



(1) Authz Configure permissions for SVN group and group users




[group]
Test = user1,user2 //Create test user group and add user1 user2 user

[/] / / specify the root directory first permission
@test = rw //Set the permissions of the test group to be readable and writable 


(2) passwd Configure user password





[users]

User1 = 12345678 //Username is the user who added the member to the group
User2 = 12345678 


(3) svnserve.conf configuration repository information and user files and user password file path, repository path





[general]
Anon-access = none //others can't read
Auth-access = write //Set the permissions of the user in authz to be writable
Password-db = passwd //point to your own passwd file
Authz-db = authz //point to authz file
Realm = /home/svn/test 


The above is to configure SVN permissions, user account password and warehouse path



At this point, you need to restart the SVN and restart the mode below





Ps -ax | grep svn //detect svn process

Kill -9 ****** // Kill the process by kill -9 way ***** is the corresponding pid

Svnserve -d -r /home/svn //Start the svn service, of course, if you want to start a specific repository, you can write the path in more detail. 


4. Implementing synchronous Code with Post-commit



Code synchronization needs to use the Post-commit hook file to the hooks file directory, under hooks Many tmpl files, these files are hooks of the template,
If you need to use it, copy a copy and remove the. Tmpl suffix to use



(1) Generate a new valid hook file Post-commit





CP POST-COMMIT.TPML Post-commit
chmod 777 Post-commit//Set the permissions of the Post-commit file remember that this step must not leak, or later run will be an error


This will generate a valid Post-commit file.



(2) Synchronous code operation





#!/bin/sh
Export LANG=en_US.UTF-8
SVN_PATH=/usr/bin/svn
WEB_PATH=/data/wwwroot/default/test //test directory on your project directory
$SVN_PATH update $WEB_PATH --username user1 --password 12345678 //remember --username --password is two -


(3) Enter the server directory and checkout the project.





SVN Co SVN://localhost/test/  /data/wwwroot/default/test--username user1--password 12345678 


This way, your code synchronization has been implemented.



5. Client Use



All you need to do is download a TortoiseSVN turtle and pull down the test repository, then put the code in the Warehouse folder, add the file and then commit, and your project will sync to the server.



6. The mistakes that I encountered



1. First client connection to SVN server error, the connection failed because my firewall does not turn on 3690 (svn default port), you just need to open
No, look at this link http://www.linuxidc.com/Linux/2012-09/70785.htm



2. Synchronization failure is due to the permissions of the Post-commit file, you only need to set the permission to more than 755



3. Hint * * * is a direcitory/usr/bin/svnyou got this wrong, he's not a directory, it's the SVN path.












Use SVN sync code on linux Server CentOS to project


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