1. 安装SVN
![](https://img-blog.csdnimg.cn/img_convert/6a2f3599d1c6ea2b7c79c5f23969979b.png)
点击下载SVN客户端、注意找对应的版本,我使用Windows 64bit
![](https://img-blog.csdnimg.cn/img_convert/f7045cc9296f6370814749189b64cb85.png)
![](https://img-blog.csdnimg.cn/img_convert/d8d07c0c795fddc4613d6603ea02e583.png)
![](https://img-blog.csdnimg.cn/img_convert/09c941e0585eece756a5e94c8036caa6.png)
下载汉化包
![](https://img-blog.csdnimg.cn/img_convert/fa7cd6634ec64f5d4baae9056a259108.png)
下载完逐个安装即可。
成功显示:
2. SVN基本操作:
首先可以新建一个项目用来练习:
![](https://img-blog.csdnimg.cn/img_convert/ca294114eaf218e460c9892ceab3dbf8.png)
检出 checkout:
复制创建的项目的地址
本地目录右键选择检出
输入用户名密码,网站中的、
就会有绿色勾
![](https://img-blog.csdnimg.cn/img_convert/b081a07d0a2f713162e6b667e2086094.png)
![](https://img-blog.csdnimg.cn/img_convert/6c224159578428f23bfdee6561aa97e2.png)
新增 add
提交 commit
新增一些文件,选择提交,网站中会有相同母目录结构的文件
![](https://img-blog.csdnimg.cn/img_convert/8ee412c5e85a76bdfcc59978e9c27d01.png)
commit完之后网站上就会同步
![](https://img-blog.csdnimg.cn/img_convert/bfbe9d0eba74b003ebc68e7c52a735c6.png)
更新 update
![](https://img-blog.csdnimg.cn/img_convert/f4e13496bd50a8613210f4913ea0eff5.png)
历史记录
选择查看日志:
![](https://img-blog.csdnimg.cn/img_convert/e1b095a82b20b0423c0c14e0066b50b2.png)
![](https://img-blog.csdnimg.cn/img_convert/a5f0bf67165b8df975c40335ab63bb5f.png)
3. SVN的撤销和恢复
1. 撤销本地修改
本地代码写错,还没有commit时
![](https://img-blog.csdnimg.cn/img_convert/35ed06fe8cb1ff957a861dc4a44654ea.png)
2. 撤销已提交内容
已经将commit后:找到日志管理然后恢复
然后在此提交到服务端
![](https://img-blog.csdnimg.cn/img_convert/8faace7d0c3e9d66ef764ad73665c403.png)
3. 恢复到指定版本
![](https://img-blog.csdnimg.cn/img_convert/0a609616a9cdef489e54c75c12ee4b49.png)
4. 忽略文件和文件夹
忽略文件夹:
![](https://img-blog.csdnimg.cn/img_convert/befa0bba5ba5a630dfce93e4ea21a555.png)
忽略文件:
![](https://img-blog.csdnimg.cn/img_convert/891188a913849b006419cf8d66b4870d.png)
同理,忽略删除类似。
5. SVN解决冲突
什么情况容易发生冲突? 多个人律改了同个文件的同一行无法进行合并的二进制文件怎么避免冲突? 经常update同步下他人的代码二进制文件不要多个人同时操作冲突了怎么办? 解决冲突很简单,不用怕
![](https://img-blog.csdnimg.cn/img_convert/782fad291b7aa3bd324b8f3ed5f1005b.png)
解决方法:
用他人的
用自己的
编辑冲突
![](https://img-blog.csdnimg.cn/img_convert/290402777bac307591df7359756c9d20.png)
![](https://img-blog.csdnimg.cn/img_convert/f993acf2cc014c3963e649df60d37e77.png)
解决后标记已解决
修改二进制文件:例如图片等
6. 分支
什么时候需要开分支? 隔离线上版本和开发版本大功能开发,不想影响到其他人,自己独立开个分支去开发
sVN经典目录结构:trunk 主干 开发中的文件branchestags
当开发分支trunk开发完后,向branches中开辟一个上线分支:
![](https://img-blog.csdnimg.cn/img_convert/c240b2d4f8f2fd9f94682de2017a7a87.png)
![](https://img-blog.csdnimg.cn/img_convert/57b6dbe5ccf3796f28cbf52640dc32de.png)
也可以把某一个分支单独的Checkout出来,修改单独出来的不会影响其他的
![](https://img-blog.csdnimg.cn/img_convert/5a55233cac51b4fb0182e63b49a95827.png)
分支合并
分支切换:线上1.0 切换到2.0
7. 暂存
有什么用?
代码改了很多,突然篙要紧急修复一个bug,但是代码还没写完,不能提交。
代码重构了很多,突然需要发布新版本,但是代码还跑不起来,不能提交。
![](https://img-blog.csdnimg.cn/img_convert/05d42afeec5c1fda8758bde8862b7fb5.png)
8. 复杂代码合并
?:主千开发新功能,改了很多分支是线上版本,修复了很多bug两个分支的代码时间久了差异很大,无法直接分支合并或者指定提交记录合并代码使用Beyondcompare