当前位置:网站首页>Alibaba cloud server builds SVN version Library

Alibaba cloud server builds SVN version Library

2022-07-06 16:55:00 LuckyShawn

Build and use SVN

Preface

Subversion(SVN) It's an open source version control system , in other words Subversion Managing data that changes over time .

The data is placed in a central repository (repository) in . This archive is very similar to a normal file server , But it remembers every file change . So you can restore the file to the old version , Or browse the history of file changes .

SVN Some of the concepts of

  • repository( Source code library ): The place where the source code is stored
  • Checkout( extract ): When you have no source code , You need to go from repository checkout A source code
  • Commit( Submit ): If you have modified the code , You need to Commit To repository
  • Update( to update ): When you have Checkout A copy of the source code ,Update once , You can work with Repository Source code synchronization on , The code in your hand will have the latest changes

The daily development process is actually like this ( Suppose you have Checkout And I've been working for a few days ):Update( Get the latest code )—> Make your own modification and debug successfully —> Commit( You can see your modification ).

If you and your colleagues modify the same file at the same time ,SVN You can merge your changes , actually SVN Managing source code is done in units of behavior , That is, as long as you don't modify the same line of program ,SVN Both changes are automatically merged . If it's the same line ,SVN Will prompt the file Confict( Conflict ), Need to confirm manually .

install SVN

You can use any of the following methods to install SVN.

Use SVN Version control image
You can buy and use in the cloud market SVN Version control image Of ECS example .

After the instance is created , Follow these steps :

  1. Sign in ECS Administrative console .
  2. In the left navigation bar , single click example .
  3. Choose the region .
  4. Find the newly created ECS example , stay IP Address List the public network of the instance IP Address .

Manual installation SVN Manual installation SVN
This article takes CentOS 7.2 64 For example, bit system , Explain how to use CentOS 7.2 Installation on SVN.

  1. Remote connection Linux example .
  2. Run the following command to install SVN.
yum install subversion
  1. Run the following command to see SVN edition .
svnserve --version

 Insert picture description here

  1. Follow these steps to create a version Library :
  • Run the following command to create a directory .
mkdir /var/svn
  • Run the following commands in sequence to create the version Library .
cd /var/svn
svnadmin create /var/svn/svnrepos
  • Run the following commands successively to view the automatically generated version library file .
cd svnrepos
ls

 Insert picture description here

Subversion Directory description :

  1. db Catalog : All version control data storage files .
  2. hooks Catalog : place hook Directory of script files .
  3. locks Catalog : The client used to track access to the file library .
  4. format file : It's a text file , There's only one integer in it , Represents the version number of the current file library configuration .
  5. conf Catalog : This is the configuration file of the warehouse ( User access account of the warehouse 、 Authority, etc ).
  • Run the command cd conf/ Get into conf Catalog ( The SVN Version library configuration file ). The results are as follows :
    1. authz: It's a permission control file .
    2. passwd: It's an account and password file .
    3. svnserve.conf:SVN Service profile .

Follow the steps below to set the account and password :

vi passwd.
  • 1. Press i Key to enter edit mode .

  • 2. stay [users] Add user account and password to the block , Format : account number = password , For example, in the example suzhan = redhat( Note that there should be a space at both ends of the equal sign ).

  • 3. Press Esc Key to exit edit mode , And enter the :wq Save and exit .

  • Follow these steps to set permissions :

 function  vi authz.
  1. Press i Key to enter edit mode .
  2. Add the following code at the end ( among ,r Express reading ,w Said to write ):
    [/]
    suzhan=rw
  3. Press Esc Key to exit edit mode , And enter the :wq Save and exit .
     Insert picture description here

Follow the steps below to modify svnserve.conf file .

  1. Run the command vi svnserve.conf.
  2. Press i Key to enter edit mode .
  3. Open the following comments ( Note that each line cannot start with a space , There should be a space at both ends of the equal sign ):
anon-access = read # Anonymous users can read , You can also set  anon-access = none, Anonymous users are not allowed to access . Set to  none, The log date can be displayed normally 
auth-access = write # Authorized users can write 
password-db = passwd # Which file is used as the account file 
authz-db = authz # Which file is used as the permission file 
realm = /var/svn/svnrepos # Authentication space name , Version Library Directory 
  1. Press Esc Key to exit edit mode , And enter the :wq Save and exit .

Run the following command to start SVN Version Library .

svnserve -d -r /var/svn/svnrepos
 Run the command  ps -ef |grep svn  see SVN Whether the service is on .

If the returned result is as shown in the figure below , Express SVN The service has been turned on .

 Insert picture description here

 explain   Run the following command to stop SVN command .
killall svnserve

Add security group rule

SVN The default port for the service is TCP 3690. You need to log in ECS Administrative console , Add security group rule release TCP 3690 port .

stay Windows Up test

This section explains how to get local (Windows operating system ) visit ECS Installed on the instance SVN service .

Install... On the local machine TortoiseSVN client .

In your local project folder ( As in the example C:\KDR), Right click the blank space to pop up the menu , choice SVN Check out the .
 Insert picture description here
Specify Repository URL, The format is svn:// Instance public network IP Address / Resource library name ; Appoint Check out to directory ( As in this example C:\KDR); Click again determine .
 Insert picture description here
If the message shown in the figure appears , Indicates that the check-out is successful .
 Insert picture description here

explain Password required for first login , All with passwd The account password in the file is mainly .

Modify and submit the project
After downloading the project to the local machine , You can add files in 、 Modify file 、 Delete files, etc .

Commit changes

Follow the steps below to submit the modification :

Right click in the blank space of the project file , choice SVN Submit .
 Insert picture description here

Enter the version update information submitted this time ( Comments on the changes made )、 Check the operation content to be submitted , single click determine , You can submit the local project to SVN Server repository , Overwrite the repository item to realize the update .
explain
If there is a submission conflict , That is, both of them submit modifications , The post submitter will fail to submit due to the backward version . At this time, you can back up your project first , After downloading the latest project from the server , Then overwrite your project to the local project folder , Last SVN Submit to successfully submit .
Suppose you just deleted a file , The information shown in the screenshot below will be displayed here
.
 Insert picture description here

Get updates

If someone else modifies SVN Items on the server repository , You want to download the latest project , Right click the blank space of the local project file , choice SVN to update , Download can be completed automatically , It will also prompt what updates have been made .

explain Select... In the original project folder SVN to update , Will automatically overwrite the original content . We recommend that you back up , Update again , Prevent your original project content from being lost .

SVN Restore

Open a folder , Right click to check out data .
Delete the data .
Take different actions according to whether you have submitted the modification :
When not submitted , Right click the blank space , choice TortoiseSVN > SVN Restore .
When submitted , The data in the system library will also be synchronized , The system will also delete its stored data . here , You need to take the following methods to restore data :
Check the log , Confirm which files have been deleted .
 Insert picture description here

Save the deleted file version to the deleted location .
 Insert picture description here
Open the original folder , choice SVN Submit , The data in the system library is synchronized with this file .

原网站

版权声明
本文为[LuckyShawn]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131313124415.html