The article turns to my personal blog: https://cainluo.github.io/14785314208383.html


The author testimonials

Some time ago, WHEN I was writing a project without the Internet, I found it very painful. I didn’t know how to version management. Suddenly, I had a flash of inspiration and set up a local SVN server

** Finally :** ** If you have better suggestions or dissatisfaction with this article, please contact me, I will refer to your comments and then modify, when contacting me, please note ** ‘Build Mac OS local SVN server’ ** If you feel good, Hope you can also give a tip ~ hee hee ~ wish you a happy learning ~ thank you ~**


Creating a SVN Server

First we need to create a SVN server folder. Here my address is as follows:

    sudo svnadmin create /Users/imac/Documents/svn/MyCode
Copy the code


Configure the SVNserve. conf file

After the creation, you need to configure SVN. I am used to using Vim here. The directory on my machine is as follows:

sudo vim /Users/imac/Documents/svn/MyCode/conf/svnserve.conf 
Copy the code

When you have entered several parameters, be sure to delete the **# and space ** before them.

  • Anon-access = none(default: read, change to none)
  • auth-access = write
  • password-db = passwd
  • authz-db = authz


Configure the Passwd file

After configuring the SVNserve. conf file, proceed to configure the passwd file:

    sudo vim /Users/imac/Documents/svn/MyCode/conf/passwd 
Copy the code

Here we just need to add a username and password, after all, only you use it.

    admin=123456
Copy the code


Configure the Authz file

Once you’ve configured the first two files, you’re done with the next one

    sudo vim /Users/imac/Documents/svn/MyCode/conf/authz
Copy the code
[groups]

admins=admin

[/]
@admins=rw
Copy the code


Starting the SVN Server

So much configuration, the most important thing is to start our SVN server

    svnserve -d -r /Users/imac/svn/MyCode
Copy the code

If no message is displayed, it indicates that the SVN server is successfully started.


Shutting down the SVN Server

There are starts, and there are shuts

    sudo killall svnserve
Copy the code

Or turn on the activity monitor to search before clicking away


Import the project file to the SVN server for the first time

SVN server is ready, now is to import project files to the server

    svn import /Users/imac/Documents/AFNetworking svn://localhost/MyCode --username=admin --password=123456 -m "Initialize import"
Copy the code

Here’s what this command means:

  • / Users/imac/Documents/AFNetworking this paragraph refers to the need to import the project file.
  • SVN ://localhost/MyCode means to upload the project file to the directory MyCode.
  • –username=admin –password=123456 specifies the verification username and password.
  • **-m “Initialize the import “** refers to the committed information.

Download the project file from the SVN server to the local PC

We already know about upload project, so let’s talk about download project.

    svn checkout svn://localhost/mycode --username=admin --password=123456 /Users/imac/Documents/code
Copy the code

I’m not going to explain it here.


Resubmit the code to the server

The premise of the second submission is that you need to download the code locally from the SVN server, and then modify the code to make the second submission. First we have to go to the project catalog:

    cd /Users/imac/Documents/code
Copy the code

Then enter the command:

    svn commit -m "Modify some code"
Copy the code

This way can the * * / Users/imac/Documents/code this directory all the modified code is submitted to the server These are based on terminal operation case, I recommend using a Cornerstone of * *, more simple and convenient, as for where there is a free version, Probably can go baidu search, a pile of a pile of ~~


Permissions error

If you have an E000013 error while importing the project:

svn: E000013: Can't open file '/Users/xxx/Documents/svn/XXX/db/txn-current-lock': Permission denied
Copy the code

This error is usually your SVN folder permissions are not open, just enter your SVN directory, enter the following command to solve the problem. The directory is on my side * * / Users/imac/Documents/SVN/MyCode * *

/*MyCode is the folder where you create the SVN server */ sudo chown -r $(id -u):$(id -g) MyCode
    chmod -R u+w MyCode
Copy the code