How do I set up a SVN server environment on a Mac

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

Create a SVN directory in the /User/apple directory. You can create multiple warehouse directories in the SVN directory

Open the terminal, create a myCode repository, and enter the command:

svnadmin create /Users/apple/svn/mycode
Copy the code

After the command is successfully executed, a directory /Users/apple/ SVN /mycode is found on the hard disk. The directory structure is as follows:

Note: This place appears the path error can pass

Type the command

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Copy the code
2. Configure user rights on the SVN

Modify three files in the/SVN /mycode/conf directory

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

# anon-access = read
# auth-access = write
 
# password-db = passwd
 
# authz-db = authz
Copy the code

Anon-access = read indicates that anonymous access is read-only. If the value is changed to anon-access = None, anonymous access is prohibited and the user password is required for access

2. Open passwd and add the account and password under [users]. [users] mj=123 JJ =456 The account is MJ and the password is 123

Authz allows you to add users to passwd and assign them to different user groups. Later, you can set different permissions for different user groups. There is no need to set individual permissions for each user.

Add the group name and user name under [groups], separated by commas (,)

[groups] topgroup=mj,jj Indicates that mj and JJ belong to topgroup.

Use [/] to represent all resource libraries on the SVN server

[/] @topgroup=rw All users in the topgroup have rW permissions on all resource libraries. The group name must be preceded by @

If it is a user name, do not add @. For example, the user MJ has read and write permission

[/] mj=rw For more detailed permission controls, see the rest of the Authz file

4. After all the configurations before starting the SVN server, the most important thing is whether the server can be started properly. If the server cannot be started, no amount of previous work is in vain.

Enter the following command at the terminal:

svnserve -d -r /Users/apple/svn
Copy the code

Or enter:

svnserve -d -r /Users/apple/svn/mycode
Copy the code

If there is no prompt, the startup is 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.

3. Use the SVN client function

1. Import code from local to server (first initial import) and enter it in terminal

svn import /Users/apple/Documents/eclipse_workspace/weibo
svn://localhost/mycode/weibo --username=mj --password=123 -m "Initialize import"
Copy the code

I will explain the directive meaning: / Users/apple/all of the Documents/eclipse_workspace/weibo content, uploaded to the server mycode weibo directory of the warehouse, the double quotation marks in the “initialization import” is a comment

Note: Apple is the user name

2. Download the code from the server to the client and enter it on the terminal

svn checkout svn://localhost/mycode --username=mj --password=123 /Users/apple/Documents/code
Copy the code

I will explain the directive meaning: the server mycode to download the contents of the warehouse to/Users/apple/Documents/code directory

Note: Localhost can be replaced with the IP address of your local server. When you share a SVN with someone else, you can enter the IP address of the server where you want to make data requests.

3. Submit the changed code to the server in step 2 has been download the server-side code to/Users/apple/Documents/code directory, now some modification on the surface of the item code, and then submit the change to the server

1 > open a terminal, to locate to/Users/apple/Documents/code directory, type:

cd /Users/apple/Documents/code
Copy the code

2> Enter the submit instruction:

svn commit -m "Modified the main.m file"
Copy the code

This command will/Users/apple/Documents/code of all changes are synchronized to the server, if this time I only change the main. file

You can see the printed information of the terminal:

Sending        weibo/weibo/main.m
Transmitting file data .
Committed revision 2.
Copy the code

4. Update the server-side code to the client This should be the most simple instructions, positioning in the terminal to the client code directory, such as the above/Users/apple/Documents/code directory, and then input instructions: SVN update

5. You can enter other uses of SVN on the terminal

: SVNhelp
Copy the code

Note:

  • The built-in SVN of the system cannot support update of locally deleted files. That is, when you update files on the server after deleting files locally, the deleted files are downloaded from the folder on the server to your local folder. However, it does support the update operation after file modification.
  • Remember to comment, otherwise the system will not recognize the command.