`
zccst
  • 浏览: 3291490 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

[svn] 解决SVN冲突攻略(手册)

阅读更多
zccst翻译

This tutorial is walkthough on how to resolve a conflict in svn (subversion)
这个手册是解决svn冲突的攻略

First I will make a test.txt
首先,我创建了一个名为test.txt的文件(在svn服务器端),并录入如下内容

test

Now I will commit the changes
现在我们提交刚刚添加的内容

C:\workspace\test>svn ci -m "making a starting point"
Sending        .
Sending        test.txt
Transmitting file data .
Committed revision 2.

Suppose we have 2 users. User1 and User2. Both of them will get and update from svn
假设我们有用户1和用户2两个人通过svn客户端获取svn服务器端的文件test.txt

C:\workspace\test>svn up
A    test.txt
At revision 2.

Now User1 will change the file to:
现在用户1更改文件test.txt内容为如下

User1 is making a conflict test

He then commits his changes
然后用户1提交刚才的更改

C:\workspace\test>svn ci -m "User1 starting a conflict"
Sending        .
Sending        test.txt
Transmitting file data .
Committed revision 3.

User2 now comes along and changes his local copy of the file not knowing that it has already been updated by User1 on the server.
用户2也对文件test.txt做了更改,此时他并不知道用户1做了更改并已提交。

test User2 making a conflict

When he tries to commit he will get and error from svn.
当用户2修改文件test.txt完毕后,准备提交时出错。

svn: Commit failed (details follow):
svn: File or directory 'test.txt' is out of date; try updating
svn: resource out of date; try updating

So User2 performs an update
根据错误提示,用户2更新了文件test.txt(此时发生了冲突)

C:\workspace\test>svn up
Conflict discovered in 'test.txt'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options:
svn detects that theres a conflict here and require you to take some kind of action.


If you type ‘s’ here you will get a list of the commands and meaning
如果你输入s选项,则会列出所有svn解决冲突的选项,如下所示:

(e)  edit             - change merged file in an editor               #直接进入编辑
(df) diff-full        - show all changes made to merged file          #显示更改至目标文件的所有变化
(r)  resolved         - accept merged version of file

(dc) display-conflict - show all conflicts (ignoring merged version)  #显示所有冲突
(mc) mine-conflict    - accept my version for all conflicts (same)    #冲突以本地为准
(tc) theirs-conflict  - accept their version for all conflicts (same) #冲突以服务器为准

(mf) mine-full        - accept my version of entire file (even non-conflicts)#完全以本地为准
(tf) theirs-full      - accept their version of entire file (same)    #完全以服务器为准

(p)  postpone         - mark the conflict to be resolved later        #标记冲突,稍后解决
(l)  launch           - launch external tool to resolve conflict
(s)  show all         - show this list


【选择处理方式一:df】

If you type ‘df’ it will show you a all the conflicts in the following format
选择选项df,则会按如下格式显示所有冲突

Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: df
--- .svn/text-base/test.txt.svn-base    Tue Aug 10 10:59:38 2010
+++ .svn/tmp/test.txt.2.tmp     Tue Aug 10 11:33:24 2010
@@ -1 +1,3 @@
-test
\ No newline at end of file
+<<<<<<< .mine +test User2 making conflict======= +User1 is making a conflict test>>>>>>> .r3
‘e’ option will open the conflicted file in the text editor that you configured for svn to use. In this case it will show

<<<<<<< .mine test User2 making conflict======= User1 is making a conflict test>>>>>>> .r3


You can resolve the conflict here by changing the text to what you desire.
For example:
你可以解决冲突通过改变文件内容,例如vim test.txt

User1 is making a conflict test User2 making conflict

save your changes and exit your text editor and it will give you the conflict options again. Now if you use the ‘r’ it will mark the file is merged with a ‘G’.  A status of ‘G’ means there was a conflict and it has been resolved.
保存更改,又出现刚才的选项。此时你使用r选项,则会合并文件。如下所示:

Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: e
Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: r
G    test.txt
Updated to revision 3.

you can now check the status with svn status. You see that test.txt is marked as ‘M’ all thats left to do is commit.
检查svn状态,你会发现文件test.txt前面已变成M

C:\workspace\test2>svn st
M       test.txt

C:\workspace\test2>svn ci -m "conflict resolved"
Sending        test.txt
Transmitting file data .
Committed revision 4.


【选择处理方式二:p】

Sometimes the conflicts are a bit more extensive and it requires more time or better tools to resolve the conflict in these cases you can chose ‘p’ to postpone the resolution.
有时,冲突会复杂一些,可能需要借助其他工具才能解决,这时你可以使用选项p

Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: p
C    test.txt
Updated to revision 3.
Summary of conflicts:
  Text conflicts: 1

Now if you look in your directory you will see that svn has created a few extra files for you.
此时,查看当前文件夹下,出现了如下几个文件

08/10/2010  11:44 AM                94 test.txt
08/10/2010  11:44 AM                26 test.txt.mine
08/10/2010  11:44 AM                27 test.txt.r2
08/10/2010  11:44 AM                31 test.txt.r3

The test.txt file is now a file with both User2 and User1′s changes but marked.
文件test.txt包含了用户1和用户2的更改。

<<<<<<< .mine test User2 making conflict======= User1 am making a conflict test>>>>>>> .r3

test.txt.mine is User2′s copy.
文件.txt.mine保存了用户2的内容

test User2 making conflict

test.txt.r2 is the original base copy
文件.txt.r2是未冲突前的内容

test

test.txt.r3 is the copy User1 commited
文件.txt.r3保存了用户1的内容

User1 is making a conflict test

At this point you can choose your favorite merge tools to merge the differences in a file.
这种情况下,你可以选择自己喜欢的对比工具,查看差别。

I suggest merging the differences into test.txt and the do a
我建议和并不同至文件test.txt中,如果如下命令:

C:\workspace\test>svn resolve --accept working test.txt

Resolved conflicted state of 'test.txt'

You can also use any of the other files if you wanted to and just pass resolve –accept a different argument. Here are the valid arguments
当然,你也可以使用其他文件,使用resolve -accept 加其他参数,共6个

实例:
svn resolve mail.sh --accept 'mine-conflict'     #解决冲突。
svn resolved mail.sh                                          #告知svn。4个文件中的其他3个消失


(1)#svn resolve –accept base
Choose the file that was the BASE revision before you updated your working copy. That is, the file that you checked out before you made your latest edits.
使用1.txt.r2作为最后提交的版本

(2)#svn resolve –accept working
Assuming that you've manually handled the conflict resolution, choose the version of the file as it currently stands in your working copy.
使用当前拷贝即test.txt作为最后提交的版本

(3)#svn resolve –accept mine-full
Resolve all conflicted files with copies of the files as they stood immediately before you ran svn update.
使用test.txt.mine作为最后提交的版本

(4)#svn resolve –accept theirs-full
Resolve all conflicted files with copies of the files that were fetched from the server when you ran svn update.
使用test.txt.r3作为最后提交的版本

(5)#svn resolve –accept mine-conflict
冲突的部分以本地修改为准

(6)#svn resolve –accept theirs-conflict
冲突的部分以服务器端修改为准

执行一下:svn resolved test.txt。


Now you are ready to commit.
然后提交

C:\workspace\test>svn ci -m "conflict resolved"
Sending        test.txt
Transmitting file data .
Committed revision 4.


如果您觉得本文的内容对您的学习有所帮助,您可以微信:

  • 大小: 28.9 KB
分享到:
评论
1 楼 long5493 2013-05-29  
步骤很详细,直接就明白了,好帖子

相关推荐

    svn中文手册 PowerDesigner中文手册

    svn中文手册 PowerDesigner中文手册

    SVN使用手册中文版快速入门

    解决冲突(合并别人的修改) 手工合并冲突 拷贝覆盖你的工作文件 下注:使用svn revert 提交你得修改 检验历史 svn log svn diff 比较本地修改 比较工作拷贝和版本库 比较版本库与版本库 svn cat svn list 关于历史...

    myeclipse svn 详细操作手册与版本冲突解决办法

    Myeclipse svn 插件详细使用操作手册与版本冲突解决办法,以及同步项目图标介绍与区分。写于2012-04-19.如有不详,请联系- 新浪@我的中餐在那里

    AnkhSvn操作手册

    9 2.4.4 什么是冲突合并视图 10 3 开始使用 AnkhSvn10 3.1 安装 AnkhSVN 10 3.2 在 VisualStudio 中启用 AnkhSvn 10 3.3 将项目连接到 AnkhSVN 11 3.4 增加解决方案到版本库 12 3.5 浏览版本库13 3.6 增加工作拷贝到...

    SVN使用手册中文版.chm

    解决冲突(合并别人的修改) 手工合并冲突 拷贝覆盖你的工作文件 下注:使用svn revert 提交你得修改 检验历史 svn log svn diff 比较本地修改 比较工作拷贝和版本库 比较版本库与版本库 svn cat svn list 关于历史...

    SVN使用手册大全

    目 录 1. 修改 SVN 访问密码 2. SVN 客户端使用说明 ...2.3.11. 解决冲突 2.3.12. 忽略无需版本控制的文件 2.3.13. 去除 SVN 标志 2.3.14. 查看文件每行的修改信息 2.3.15. 重置访问路径 2.3.16. 本地路径转换

    SVN使用手册,有图有说明

    2.3.11. 解决冲突 2.3.12. 忽略无需版本控制的文件 2.3.13. 去除SVN标志 2.3.14. 查看文件每行的修改信息 2.3.15. 重置访问路径 2.3.16. 本地路径转换 2.4. 浏览版本库 2.5. 建立标签 2.6. 建立分支 2.7. ...

    SVN操作手册中文版网页格式

    转换后为网页格式的&lt;SVN操作手册中文版&gt; 目录 译者序 前言 序言 读者 怎样阅读本书 本书约定 排版习惯 图标 本书组织结构 Subversion 1.1的新特性,svn客户端和linux下命令行。 目录 1. 简介 1.1. 什么是 ...

    svn操作手册

    svn详细的图文教程,安装指南,操作指南,冲突解决案例,使用注意事项

    SVN客户端用户使用手册

    SVN客户端用户使用手册 20061115 该文档将逐步教您如何在软件开发过程中使用svn客户端 环境模拟 现有项目名称:test 服务端版本库:test URL:http://10.155.11.10:81/svn 开发人员:devA,devB 版本库目录结构: ...

    svn使用手册

    解决代码冲突困难 容易引发BUG 难于追溯问题代码的修改人和修改时间 难于恢复至以前正确版本 无法进行权限控制 项目版本发布困难 为保障团队开发过程中人员沟通各方面成本的降低,必须使用一种有效的方式减少沟通...

    开源版本控制SVN管理后台pySvnManager用户使用手册(pysvnmanager user-guide)

    pySvnManager 是群英汇开发的一个Subversion 的管理后台,用 Python 写的一个 Web 应用,用于管理 SVN 授权文件,只需要一个 SVN 授权文件即可工作,并且使用扩展的 SVN 授权文件进行 pySvnManager 本身的授权,而...

    SVN使用手册

    该手册有详细的安装步骤、解决冲突、提交、检出、修改等等

    SVN安装配置及使用说明

    4.5.4 合并冲突 35 第五章 客户端使用说明——AnkhSvn 40 5.1 初始化导入 40 5.2 SVN检出 42 5.3 工作平台中文件的修改及版本库的提交 43 5.4 AnkhSvn的常规功能说明 45 常用功能1 45 常用功能2 50 第六章 注意事项 ...

    TortoiseSVN-1.9.2使用手册(中文版)pdf

    TortoiseSVN-1.9.2使用手册(中文版)pdf,包括如何安装、如何使用,常见的问题:如何解决冲突等

    subversion-TortoiseSVN-使用手册(CHM+HTML,中英完整版)

    5.6. 解决冲突 5.7. 获得状态信息 5.7.1. 图标重载 5.7.2. 在Windows资源管理器中的TortoiseSVN列 5.7.3. 本地与远程状态 5.7.4. 查看差别 5.8. 版本日志对话框 5.8.1. 调用版本日志对话框 5.8.2. 获得更多信息 ...

    唯品会Java开发手册.zip

    通过集成Git、SVN等版本控制系统,支持团队成员间的代码共享、分支管理、合并请求和冲突解决。 可视化设计与原型制作: 对于UI/UX设计,有界面设计工具,如Sketch、Adobe XD,可以帮助设计师快速构建应用程序...

    TortoiseSVN中文手册

    3.2.6. 使用 svn+ssh 认证 ........................................... 28 3.2.7. svnserve 基于路径的授权 ...................................... 28 4. 版本库 ................................................

    测试笔记(从零开始)

    六、 分支冲突的解决 112 第十二章 系统测试 117 概念: 117 分类: 117 功能测试:(Function testing中国 Feature testing国际) 118 性能测试:(Sercarity testing) 118 安全性测试:(Security Testing) 118 ...

    ctest

    冲突 介绍 {以下是Gitee平台说明,您可以替换此简介Gitee是OSCHINA推出的基于Git的代码托管平台(同时支持SVN)。 ,或者企业,都能够用Gitee实现代码托管,项目管理,协作开发。企业项目请看 } 软件架构 软件架构...

Global site tag (gtag.js) - Google Analytics