SVN 学习笔记

参考:

  SVN教程 https://www.runoob.com/svn/svn-tutorial.html

1. SVN 的一些概念

repository(源代码库):源代码统一存放的地方
Checkout(提取):当你手上没有源代码的时候,你需要从repository checkout一份
Commit(提交):当你已经修改了代码,你就需要Commit到repository
Update (更新):当你已经Checkout了一份源代码, Update一下你就可以和Repository上的源代码同步,你手上的代码就会有最新的变更。
update 操作是用来更新版本库的。这个操作将工作副本与版本库进行同步。

  日常开发过程其实就是这样的(假设你已经Checkout并且已经工作了几天):Update(获得最新的代码) -->作出自己的修改并调试成功 --> Commit(大家就可以看到你的修改了) 。

  如果两个程序员同时修改了同一个文件呢, SVN 可以合并这两个程序员的改动,实际上SVN管理源代码是以行为单位的,就是说两个程序员只要不是修改了同一行程序,SVN都会自动合并两种修改。如果是同一行,SVN 会提示文件 Conflict, 冲突,需要手动确认。
SVN 的主要功能


2. 相关笔记

svn copy 是用来创建分支的,例如# svn copy trunk/ branches/my_branch

svn 中应该 commit 就是提交到远程版本中,相当于git push。

svn 中一旦一个文件使用 svn add 添加到 svn 中,之后修改这个文件后直接 svn commit 即可,不需要再执行 svn add 此文件了,这点和git不同。

svn update 应该是相当于 git pull

svn 的操作流程应该是: svn update ---> 修改 ---> svn commit


3. 试验

创建SVN版本库"proper_1"/home/ubuntu/mytest/svn_test# svnadmin create proper_1

checkout一个版本库的副本:
/home/ubuntu/mytest/svn_test/client1# svn checkout file:///home/ubuntu/mytest/svn_test/proper_1
//这里使用的是文件协议,实际使用中可以将其替换为远程服务器上的版本库


测试添加文件
/home/ubuntu/mytest/svn_test/client1/proper_1# touch first.txt

/home/ubuntu/mytest/svn_test/client1/proper_1# echo hello > first.txt

/home/ubuntu/mytest/svn_test/client1/proper_1# svn status 
?       first.txt

/home/ubuntu/mytest/svn_test/client1/proper_1# svn add first.txt
A         first.txt

/home/ubuntu/mytest/svn_test/client1/proper_1# svn commit -m "add file: first.txt"
Adding         first.txt
Transmitting file data .
Committed revision 1.

/home/ubuntu/mytest/svn_test/client1/proper_1# svn log
------------------------------------------------------------------------
r1 | root | 2019-06-22 21:53:26 +0800 (Sat, 22 Jun 2019) | 1 line

add file: first.txt
------------------------------------------------------------------------

猜你喜欢

转载自www.cnblogs.com/hellokitty2/p/11070677.html