First, the code management platform to introduce, install SVN, using SVN (Linux) client, Windows

First, the Code Management Platform Introduction

Changes in version control, record the contents of several files for future reference a specific version of the revision

A brief history of the development of version management tools, CVS → SVN → Git

CVS: compatibility is not very good.

SVN: too slow. Full name: Subversion, an open source version control system, began in 2000.

Git: Linux founder linus initiated, released in 2005, was originally designed to better manage the Linux kernel code.

Git Git and SVN except that does not depend on the server can work, i.e. Git is distributed.


Comparative Git and SVN, refer http://blog.lishiming.net/?p=305

The main difference between the SVN and Git - distributed.

SVN advantages:

1. Storage

SVN server with both CVS advantage of data storage has, in general the data is not lost, but also has its own characteristics. SVN is by way of a relational database to store and binary, while addressing the past can not read and write the same file at the same time and other issues, while adding its own unique "zero or one" principle.

2. Speed

Compared with the initial CVS, SVN has improved so much in terms of running speed. Because SVN server supports only a small amount of information, resources, transport, compared with other systems, more support is an offline mode, thus avoiding network congestion occurs.

3. Security

SVN is a technical safer products, systems and controls to achieve a combination of both. On the one hand the whole system can be effectively distributed security features in the branch system, thus ensuring the normal operation branch system, so that the system can complement each branch, finally able to protect the integrity of the security system, to achieve the ultimate pursuit of the principle of proportionality by security purposes.


Git advantages and disadvantages:

advantage:

Suitable for distributed development , emphasis on the individual.

Public pressure on the server and the amount of data that will not be too large.

Fast and flexible.

You can easily resolve any conflict between two developers.

Work offline.

Disadvantages:

Less data (at least Chinese little information).

Learning cycle is relatively long.

Unconventional thinking.

Poor security codes, once the developer down the entire library clones can be completely open all the code and version information.


Git GitHub is based on the online web page code hosting platform, you can choose to pay for services.

Gitlab can be considered an open source GitHub, there is no direct contact.

Word distinction, git is a management tool, github git-based online platform (or called service). gitlab and github, just as a git-based code management platform provides a web interface.


Second, install SVN

# yum install -y subversion

Create Repository

# Mkdir -p / data / svnroot / myproject // the directory path customizable

# Svnadmin create / data / svnroot / myproject // initialization files in this directory

# Cd! $ / Conf #authz configured for access to the file, passwd as the password file, svnserve.conf for the SVN repository configuration file.

# vim authz  //配置文件新增内容如下:
[groups]
admins = aming,user1   //加到用户组的下面

[/]
@admins = rw   //@后面跟组名
* = r   //除了admins组以外的所有人只有只读的权限。

[myproject:/]
user1 = rw
# myproject指项目名,这种用法适合于/data/svnroot/有多个项目的情况下,这只是其中一个项目而已。
# 带冒号指的是一个项目名,这里只有一个项目,可以在这下面创建子目录dir1,dir2。可以写成[/dir1]、[/dir2]的形式。
# 两种不同的形式表达而已。一种是[/dir1]、一种是[myproject:/],一个意思。因为这里只有一个项目。

aliases:别名

groups:用户组

[/]:指的是/data/svnroot/myproject这个目录。

仓库里面的目录或者项目里面的目录,针对这些项目配置的关于用户和组的读写权限:

[/foo/bar]

[repository:/baz/fuz]

# vim passwd  //[users]下新增
[users]
aming = aming_!(*$123     ##左边是用户,右边是密码。
user1 = user1_^^^123
user2 = user2-***123

# vim svnserve.conf
[general]  ##在下面增加这5行内容
anon-access = none  ##匿名用户,没有权限
auth-access = write  ##被授权的用户,有写权限
password-db = passwd  ##用户密码存储位置
authz-db = authz  ##权限控制文件位置,这里只写一个字符串,表示这个字符串就是一个文件名,位置在当前目录下,针对svnserve.conf的相对路径。
realm = /data/svnroot/myproject  ##表示对哪一个项目生效,绝对路径。

# svnserve -d -r /data/svnroot/   //启动SVN,-d:deamon的形式,后台启动;-r:指定SVN所在路径;后面也可以跟到项目名。
# ps aux |grep svn
root       1621  0.0  0.0 162200   656 ?        Ss   19:53   0:00 svnserve -d -r /data/svnroot/
root       1623  0.0  0.0 112676   984 pts/0    S+   19:53   0:00 grep --color=auto svn
# netstat -lntp |grep svn
tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN      1621/svnserve
# iptables -nvL  //检查一下有没有防火墙规则,有的话后续操作不会太顺利。


三、客户端上使用SVN(Linux)

# yum install -y subversion  //另一台机器上安装,安装好后就可以使用svn命令了。
# mkdir svntest
# cd !$
# svn checkout svn://192.168.93.130/myproject --username=aming  //checkout,检出代码。如果你到一台机器上,从来没有连接过svn服务器的情况下,执行这一步以后,它就可以在本机上保存一个曾经你连接过的svnserve的用户名和密码。上面这条命令可以把远程服务端的myproject项目搞到本地来。
认证领域:  /data/svnroot/myproject
“aming”的密码: aming_!(*$123          //此处的密码就是配置文件中设置的密码
-----------------------------------------------------------------------
注意!  你的密码,对于认证域:

    /data/svnroot/myproject

只能明文保存在磁盘上!  如果可能的话,请考虑配置你的系统,让 Subversion
可以保存加密后的密码。请参阅文档以获得详细信息。

你可以通过在“/root/.subversion/servers”中设置选项“store-plaintext-passwords”为“yes”或“no”,
来避免再次出现此警告。
-----------------------------------------------------------------------
保存未加密的密码(yes/no)?yes   //将密码存在了/root/.subversion/servers下
取出版本 0。
[root@MRX svntest]# ls
myproject
# cd project ; ls -la
总用量 0
drwxr-xr-x 3 root root 18 8月  29 18:43 .
drwxr-xr-x 3 root root 23 8月  29 18:43 ..
drwxr-xr-x 4 root root 75 8月  29 18:43 .svn

[root@MRX myproject]# cp /etc/fstab .
# svn add ./fstab  //添加到版本控制中心,把变更的想要搞到服务器上去的东西做个标记
A         fstab
# svn commit -m "add file"   //把文件上传到服务器。先增加,再上传。
# svn commit -m "add fstab"
正在增加       fstab
传输文件数据.
提交后的版本为 1。
# svn delete filename  //在本地删除
# svn commit -m "delete filename"  //在服务器上删除
[root@MRX myproject]# svn delete fstab 
D         fstab
[root@MRX myproject]# svn commit -m "delete fstab"
正在删除       fstab

提交后的版本为 2。
# svn update  //把当前目录下的文件都更新到最新版,把本地的和服务端的同步。
# svn log  //查看变更日志
/root/.subversion/auth/svn.simple下的密码文件,如果某个用户不想存储了,可以删除这个文件。


四、客户端上使用SVN(windows)


官网 https://tortoisesvn.net/index.zh.html

下载TortoiseSVN 并安装

简明教程 http://www.jianshu.com/p/6b3b7b915332

下载好后随便选择一个文件夹,比如新建一个myproject,右键文件夹可以看到SVN Checkout和TortoiseSVN。

第一次使用时,也要先SVN checkout,点击之后,会弹出来一个窗口,在最上面的URL of repository里定义一下服务地址和项目地址就可以点OK了:svn://192.168.93.130/myproject。


点OK后再定义用户名和密码:

aming , aming_!(*$123

再点OK


试验:

在Windows的myproject目录下创建一个txt文档,内容随便写一点。再右键该文档,和在Linux上同样的操作,TortoiseSVN→add,再右键SVN commit,在上方空白框内输入add 123.txt,再点OK就可以了。


再到服务端或者另一台客户端上svn update同步一下,就可以看到123.txt了。

在Linux上写了文档,同样的操作,再到Windows上右键SVN update一下,同样可以看到这个111.txt。

# svn add 111.txt
A         111.txt
[root@MRX myproject]# svn commit -m "add 111.txt"
正在增加       111.txt
传输文件数据.
提交后的版本为 4。


Guess you like

Origin blog.51cto.com/13576245/2434465