SVN命令copy

svn copy命令的作用是拷贝某些svn版本控制的文件,生成的新文件直接纳入版本控制中
一共有

工作副本------>工作副本
工作副本------>版本库(不可跨库)
版本库------->工作副本(允许跨库)
版本库------->版本库(不可跨库)

1、 工作副本拷贝到工作副本

[root@localhost test2]# ls
aa.txt  contract.html  css  img  index.html  js
[root@localhost test2]# svn cp index.html index_bak.html
A         index_bak.html

这个命令直接代替我们使用原生的linux命令cp 拷贝某个文件,然后再使用svn add命令

拷贝某个具体版本的文件,加上-r参数,接入版本号即可

[root@localhost test2]# svn copy -r 4 index.html index_v4.html
A         index_v4.html

批量拷贝,只能是批量拷贝到某一个目录,因为同一个目录避免产生同名文件

[root@localhost test2]# svn mkdir temp
A         temp
[root@localhost test2]# ls
aa.txt  contract.html  css  img  index_bak.html  index.html  js  temp
[root@localhost test2]# svn cp contract.html index.html ./temp/
A         temp/contract.html
A         temp/index.html

2、从工作副本拷贝到版本库

这个也支持-r指定版本号的用户

[root@localhost hello]# svn cp index.html svn://192.168.8.194/hello/index_bak.html -m "拷贝index.html文 件"
正在增加副本          index.html

提交后的版本为 2。
[root@localhost hello]# svn up
正在升级 '.':
A    index_bak.html
更新到版本 2。

这个不能跨库。

[root@localhost hello]# svn cp index.html svn://192.168.8.194/world/index_bak.html -m "拷贝index.html文 件"
svn: E170009: 版本库的 UUID“1b7bc922-123e-4eeb-815e-f25bdcfdcd90”与期望的 UUID“8fe3937b-a4af-401c-9ecf-fc89928b4ebe”不匹配

3、从版本库拷贝工作副本

[root@localhost hello]# svn cp svn://192.168.8.194/hello/index.html demo.html
A         demo.html
[root@localhost hello]# ls
demo.html  index_bak.html  index.html

跨库演示:

[root@localhost world_hbk]# svn info huangbaokang.txt 
路径: huangbaokang.txt
名称: huangbaokang.txt
工作副本根目录: /root/svn/world_hbk
URL: svn://192.168.8.194/world/huangbaokang.txt
版本库根: svn://192.168.8.194/world
版本库 UUID: 1b7bc922-123e-4eeb-815e-f25bdcfdcd90
版本: 1
节点种类: 文件
调度: 正常
最后修改的作者: harry
最后修改的版本: 1
最后修改的时间: 2019-04-23 15:04:38 +0800 (二, 2019-04-23)
文本最后更新: 2019-04-23 15:03:14 +0800 (二, 2019-04-23)
校验和: da39a3ee5e6b4b0d3255bfef95601890afd80709
[root@localhost hello]# svn cp svn://192.168.8.194/world/huangbaokang.txt huangbaokang.txt
A         huangbaokang.txt

总结:提交是不能跨库的。

4、版本库拷贝到版本库

版本库到版本库的拷贝,跟工作副本完全没有关系
命令执行不需要切换到版本目录,任意位置均可

[root@localhost hello]# svn cp svn://192.168.8.194/hello  svn://192.168.8.194/hello/trunk -m "建立分支"

提交后的版本为 3。

一般在多版本应用的时候,会使用svn cp命令拷贝不同版本库到版本库,进行线上版本的控制。
业内的常见做法是建立一个主版本(trunk),和一个分支版本(branch),和一个TAG版本。

你可能感兴趣的:(svn)