1版本管理工具安装
对于程序开发来说,代码管理是日常生活的重中之重,谁也不想劳心劳力写出来的代码结果因为没有进行版本管理而无法回到一个预期的状态,这是非常糟糕的状态。因此很多职场新人在刚开始步入职场时,第一步就是要进行代码的版本管理。当前流行的版本管理工具中有两个较为优秀的工具,即集中式版本管理的SVN和分布式管理工具Git,由于出差的原因,而且搭建GIt服务器的流程并不熟悉,因此在这里简单演示搭建SVN,之后有时间会演示使用docker安装GitLab服务器。
1.1SVN安装
在有网环境下进行SVN服务器的安装较为简单,可以通过apt-get命令进行。
sudo apt-get update
sudo apt-get install subversion
1.2SVN的使用
Ubuntu给出的手册如下:
NAME
svn - Subversion command line client tool
SYNOPSIS
svn command [options] [args]
OVERVIEW
Subversion is a version control system, which allows you to keep old
versions of files and directories (usually source code), keep a log of
who, when, and why changes occurred, etc., like CVS, RCS or SCCS. Sub‐
version keeps a single copy of the master sources. This copy is called
the source ``repository''; it contains all the information to permit
extracting previous versions of those files at any time.
For more information about the Subversion project, visit http://subver‐
sion.apache.org.
Documentation for Subversion and its tools, including detailed usage
explanations of the svn, svnadmin, svnserve and svnlook programs, his‐
torical background, philosophical approaches and reasonings, etc., can
be found at http://svnbook.red-bean.com/.
Run `svn help' to access the built-in tool documentation.
在使用中关注点如下:
1.2.1 建立仓库
以思维导图阐述过程
1.2.2 配置
注意1:在修改配置文件svnserve.conf文件时,如果指定了
anon-access=read
会发现客户端无法读取仓库的日志。
注意2:在修改权限管理文件authz时要按照格式指定那些用户组可以访问什么仓库
在部署SVN时,笔者修改的文件如下:
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
### - a single user,
### - a group of users defined in a special [groups] section,
### - an alias defined in a special [aliases] section,
### - all authenticated users, using the '$authenticated' token,
### - only anonymous users, using the '$anonymous' token,
### - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = songquanheng, gaochao
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]
@admin = rw
在[groups]使用键值对配置完用户组和用户的映射关系之后,一定要继续配置用户组对仓库的访问的映射关系。
[/]
@admin = rw
不然会报错误“由于目标计算机积极拒绝,无法连接”
1.2.3 启动和停止服务
注意:在启动服务时确保路径的正确性,由于在演示中repository为仓库,因此在使用svnserve -d -r path开启服务时,要指定的路径为仓库的父目录。以下方式是错误的。
~~svnserve -d -r /home/svn/repository~~
1.2.4 访问和代码提交
1.2.4.1Windows下拉代码
确保conf/svnserve.conf中项
anon-access=none
使用TortoiseSVN查看日志如下:
1.2.4.2 Ubuntu系统
通过apt-get 安装了Subervison之后,只要用户权限足够,在本系统自然也可以克隆仓库中的代码。
sqh@sqh-virtual-machine:~/SVN/test$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:41:0c:d3 brd ff:ff:ff:ff:ff:ff
inet 172.20.10.4/28 brd 172.20.10.15 scope global ens33
valid_lft forever preferred_lft forever
sqh@sqh-virtual-machine:~/SVN/test$ svn co svn://172.20.10.4/repository
Authentication realm: <svn://172.20.10.4:3690> 53be99f7-cac1-4a79-8685-86cd244d6ffe
Password for 'sqh': #默认尝试以当前用户为用户名访问svn服务,需要输入密码验证,不适用直接enter即可
Authentication realm: <svn://172.20.10.4:3690> 53be99f7-cac1-4a79-8685-86cd244d6ffe
Username: songquanheng
Password for 'songquanheng': ******
A repository/Readme.txt
A repository/commands
Checked out revision 2.
sqh@sqh-virtual-machine:~/SVN/test$
这样就完成了使用windows和Linux克隆仓库中的代码的问题。
至于代码提交到版本库中,对于Windows和Linux虽然有区别,但遵循相同的逻辑。
1.2.4.3提交代码
2019-04-20 01:20于江宁区汉庭酒店