Use svn for project management in Mac

Mac uses svn for project management, and borrowed from http://blog.csdn.net/q199109106q/article/details/8655204
The following schemes are available for personal testing by many people

Reprint please indicate the source: http://blog.csdn.net/yc7369

In the Windows environment, we generally use TortoiseSVN to build the svn environment. In the Mac environment, since the Mac comes with svn server and client functions, we can use the svn function without installing any third-party software, but we 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 warehouse to store the code uploaded by the client

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

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

After the command is executed successfully, you will find that there is a /Users/apple/svn/mycode directory on the hard disk, and 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 # and spaces in front of the following configuration items

  1. # anon-access = read
  2. # auth-access = write
  3. # password-db = passwd
  4. # authz-db = authz
# anon-access = read
# auth-access = write

# password-db = passwd

# authz-db = authz

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

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

  1. [users]
  2. mj = 123
  3. jj = 456
[users]
mj = 123
jj = 456

The account is mj, the password is 123

3. Open authz, configure user groups and permissions

We can assign the users added in passwd to different user groups. In the future, we can set different permissions for different user groups. There is no need to set permissions for each user individually.

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

  1. [groups]
  2. topgroup=mj,jj
[groups]
topgroup=mj,jj

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

Use [/] to represent all

  1. [/]
  2. @topgroup = rw
[/]
@topgroup = rw

The above configuration shows that all users in the topgroup group have read and write (rw) permissions to all resource libraries, and @ is used in front of the group name

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

  1. [/]
  2. mj = rw
[/]
mj = rw

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

4. Start the svn server

With so many configurations in front, the most important thing is to see whether the server can be started normally. If it cannot be started, no matter how much work is done before, it will be futile.

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

或者输入:svnserve -d -r /Users/apple/svn/mycode

没有任何提示就说明启动成功了

5.关闭svn服务

如果你想要关闭svn服务器,最有效的办法是打开实用工具里面的“活动监视器”

综合上述,我们就可以轻松搭建svn服务器环境了

使用svn客户端功能

1.从本地导入代码到服务器(第一次初始化导入)

在终端中输入

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

我解释下指令的意思:将/Users/apple/Documents/eclipse_workspace/weibo中的所有内容,上传到服务器mycode仓库的weibo目录下,后面双引号中的"初始化导入"是注释

2.从服务器端下载代码到客户端本地

在终端中输入svn checkout svn://localhost/mycode --username=mj --password=123 /Users/apple/Documents/code

我解释下指令的意思:将服务器中mycode仓库的内容下载到/Users/apple/Documents/code目录中

3.提交更改过的代码到服务器

在步骤2中已经将服务器端的代码都下载到/Users/apple/Documents/code目录中,现在修改下里面的一些代码,然后提交这些修改到服务器

1> 打开终端,先定位到/Users/apple/Documents/code目录,输入:cd/Users/apple/Documents/code

2> 输入提交指令:svn commit -m "修改了main.m文件"

这个指令会将/Users/apple/Documents/code下的所有修改都同步到服务器端,假如这次我只修改了main.文件

可以看到终端的打印信息:

  1. Sending weibo/weibo/main.m
  2. Transmitting file data .
  3. Committed revision 2.
Sending        weibo/weibo/main.m
Transmitting file data .
Committed revision 2.

4.更新服务器端的代码到客户端

这个应该是最简单的指令了,在终端中定位到客户端代码目录后,比如上面的/Users/apple/Documents/code目录,然后再输入指令:svn update

5.至于svn的其他用法,可以在终端输入:svn help

这里列出一大堆svn指令,后面括号中的内容的一般代表着指令的简称,比如我们可以用svn ci代替svn commit,用svn co代替svn checkout

Mac中使用svn进行项目管理,借鉴了http://blog.csdn.net/q199109106q/article/details/8655204
以下方案多人亲测可用

转载请注明出处:http://blog.csdn.net/yc7369

在Windows环境中,我们一般使用TortoiseSVN来搭建svn环境。在Mac环境下,由于Mac自带了svn的服务器端和客户端功能,所以我们可以在不装任何第三方软件的前提下使用svn功能,不过还需做一下简单的配置。

我们首先来看下,如何在Mac环境下搭建svn服务器端环境。

创建代码仓库,用来存储客户端所上传的代码

我先在/User/apple目录下新建一个svn目录,以后可以在svn目录下创建多个仓库目录

打开终端,创建一个mycode仓库,输入指令:svnadmin create /Users/apple/svn/mycode

指令执行成功后,会发现硬盘上多了个/Users/apple/svn/mycode目录,目录结构如下:

配置svn的用户权限

主要是修改/svn/mycode/conf目录下的三个文件

1.打开svnserve.conf,将下列配置项前面的#空格都去掉

  1. # anon-access = read
  2. # auth-access = write
  3. # password-db = passwd
  4. # authz-db = authz
# anon-access = read
# auth-access = write

# password-db = passwd

# authz-db = authz

anon-access = read代表匿名访问的时候是只读的,若改为anon-access = none代表禁止匿名访问,需要帐号密码才能访问

2.打开passwd,在[users]下面添加帐号和密码,比如:

  1. [users]
  2. mj = 123
  3. jj = 456
[users]
mj = 123
jj = 456

帐号是mj,密码是123

3.打开authz,配置用户组和权限

我们可以将在passwd里添加的用户分配到不同的用户组里,以后的话,就可以对不同用户组设置不同的权限,没有必要对每个用户进行单独设置权限。

在[groups]下面添加组名和用户名,多个用户之间用逗号(,)隔开

  1. [groups]
  2. topgroup=mj,jj
[groups]
topgroup=mj,jj

明mj和jj都是属于topgroup这个组的,接下来再进行权限配置。

使用[/]代表svn服务器中的所有资源库

  1. [/]
  2. @topgroup = rw
[/]
@topgroup = rw

上面的配置说明topgroup这个组中的所有用户对所有资源库都有读写(rw)权限,组名前面要用@

如果是用户名,不用加@,比如mj这个用户有读写权限

  1. [/]
  2. mj = rw
[/]
mj = rw

至于其他精细的权限控制,可以参考authz文件中的其他内容

4.启动svn服务

前面配置了这么多,最关键还是看能否正常启动服务器,若启动不来,前面做再多工作也是徒劳。

在终端输入下列指令:svnserve -d -r /Users/apple/svn

或者输入:svnserve -d -r /Users/apple/svn/mycode

没有任何提示就说明启动成功了

5.关闭svn服务

如果你想要关闭svn服务器,最有效的办法是打开实用工具里面的“活动监视器”

综合上述,我们就可以轻松搭建svn服务器环境了

使用svn客户端功能

1.从本地导入代码到服务器(第一次初始化导入)

在终端中输入

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

我解释下指令的意思:将/Users/apple/Documents/eclipse_workspace/weibo中的所有内容,上传到服务器mycode仓库的weibo目录下,后面双引号中的"初始化导入"是注释

2.从服务器端下载代码到客户端本地

在终端中输入svn checkout svn://localhost/mycode --username=mj --password=123 /Users/apple/Documents/code

我解释下指令的意思:将服务器中mycode仓库的内容下载到/Users/apple/Documents/code目录中

3.提交更改过的代码到服务器

在步骤2中已经将服务器端的代码都下载到/Users/apple/Documents/code目录中,现在修改下里面的一些代码,然后提交这些修改到服务器

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

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

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

You can see the print information of the terminal:

  1. Sending weibo/weibo/main.m
  2. Transmitting file data .
  3. Committed revision 2.
Sending        weibo/weibo/main.m
Transmitting file data .
Committed revision 2.

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

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

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

A lot of svn commands are listed here , and the content in the brackets 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 blog.csdn.net/yc7369/article/details/38312761