The use of svn in the original Mac environment

In the Windows environment, we generally use TortoiseSVN to build the svn environment. In the Mac environment, since the Mac comes with the svn server and client functions, we can use the svn function without installing any third-party software, but we still need to do some simple configuration.

Let's first look at how to build an svn server-side environment in a Mac environment.

Create a code repository to store the code uploaded by the client

I first create a new svn directory in the /User/apple directory, and then I can create multiple warehouse directories in the svn directory

Open the terminal, create a mycode repository, and enter the command: svnadmin create /Users/svn/mycode

After the command is executed successfully, you will find that there is an additional /Users/apple/svn/mycode directory on the hard disk. The directory structure is as follows:

 

Configure svn user permissions

Mainly modify the three files in the /svn/mycode/conf directory

1. Open svnserve.conf and remove the # and spaces in front of the following configuration items

[java]  view plain copy  
  1. # anon-access = read  
  2. # auth-access = write  
  3.   
  4. # password-db = passwd  
  5.   
  6. # authz-db = authz  

anon-access = read means anonymous access is read-only, if changed to anon-access = none means anonymous access is prohibited, and an account password is required to access

 

2. Open passwd, add account and password under [users], for example:

[java]  view plain copy  
  1. [users]  
  2. mj = 123  
  3. jj = 456  

The account number is mj, the password is 123

 

3. Open authz, configure user groups and permissions

We can assign users added in passwd to different user groups. In the future, we can set different permissions for different user groups. It is not necessary to set permissions for each user individually.

Add the group name and user name under [groups], and separate multiple users with commas (,).

[java]  view plain copy  
  1. [groups]  
  2. topgroup=mj,dd  

It shows that both mj and jj belong to the topgroup group, and then configure the permissions.

Use [/] to represent all repositories in the svn server

[java]  view plain copy  
  1. [/]  
  2. @topgroup = rw  

The above configuration shows that all users in the topgroup group have read and write (rw) permissions to all resource repositories. Use @ in front of the group name.

If it is a user name, you do not need to add @, for example, the user mj has read and write permissions

[java]  view plain copy  
  1. [/]  
  2. mj = rw  

As for other fine-grained permission control, you can refer to other content in the authz file

 

4. Start the svn server

There are so many configurations in the front, and the most important thing is to see whether the server can be started normally.

Enter the following command in the terminal: svnserve -d -r /Users/apple/svn

Or enter: svnserve -d -r /Users/apple/svn/mycode

If there is no prompt, it means that the startup was successful.

 

5. Shut down the svn server

If you want to shut down the svn server, the most effective way is to open the "activity monitor" in the utility

Based on the above, we can easily build the svn server environment

 

Using the svn client function

1. Import code from local to server (initial import for the first time)

type in the terminal

svn import /Users/apple/Documents/eclipse_workspace/weibo svn://localhost/mycode/weibo --username=mj --password=123 -m "初始化导入"

Let me explain the meaning of the command: upload all the content in /Users/apple/Documents/eclipse_workspace/weibo to the weibo directory of the server mycode warehouse, and the "initialize import" in the double quotation marks is a comment

 

2. Download the code from the server to the client locally

Type svn checkout svn://localhost/mycode --username=mj --password=123 /Users/apple/Documents/code in terminal

I explain the meaning of the command: download the contents of the mycode repository in the server to the /Users/apple/Documents/code directory

 

3. Submit the changed code to the server

In step 2, the server-side code has been downloaded to the /Users/apple/Documents/code directory, now modify some of the code inside, and then submit these changes to the server

1> Open the terminal, first navigate to the /Users/apple/Documents/code directory, enter: cd/Users/apple/Documents/code

2> Enter the commit command: svn commit -m "modified the main.m file"

This command will synchronize all changes under /Users/apple/Documents/code to the server side, if I only modify the main. file this time

You can see the print information of the terminal:

[java]  view plain copy  
  1. Sending        weibo/weibo/main.m  
  2. Transmitting file data .  
  3. Committed revision 2.  

 

4. Update the server-side code to the client-side

This should be the simplest command. After locating the client code directory in the terminal, such as the /Users/apple/Documents/code directory above, enter the command: svn update

 

5. As for other uses of svn, you can type in the terminal: svn help

Here is a list of a lot of svn commands. The content in parentheses generally represents the abbreviation of the command. For example, we can use svn ci instead of svn commit and svn co instead of svn checkout

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325251027&siteId=291194637