SVN学习三——冲突

重现冲突

首先在trunk上创建一个文件Test.java的文件,里面内容如下:

public class Test {
    public static void main(string[] args) {
        int a = 1;
        int b = 2;
        System.out.println(a + b);
    }
}

然后checkout下来两个分别放在trunk1和trunk2目录下

我们首先将trunk2部分改为如下:

public class Test {
    public static void main(string[] args) {
        int a = 1;
        int b = 2;
        a = 2;
        System.out.println(a + b);
    }
}

然后commit

接下来我们修改trunk1部分:

public class Test {
    public static void main(string[] args) {
        int a = 1;
        int b = 2;
        a = 3;
        System.out.println(a + b);
    }
}

然后commit

我们会发现如下错误

Sending        Test.java
Transmitting file data .done
Committing transaction...
svn: E160028: Commit failed (details follow):
svn: E160028: 文件 “/trunk/Test.java” 已经过时

解决冲突

首先我们通过svn up命令来更新trunk1的版本,出现如下信息:

Updating '.':
C    Test.java
Updated to revision 9.
Summary of conflicts:
  Text conflicts: 1
Conflict discovered in file 'Test.java'.
Select: (p) postpone, (df) show diff, (e) edit file, (m) merge,
        (mc) my side of conflict, (tc) their side of conflict,
        (s) show all options: 

输入p

然后目录下就会出现如下文件:

Test.java
Test.java.mine
Test.java.r8  # 此处版本号可能会有所不同
Test.java.r9

打开Test.java,我们会发现里面的内容变为了如下状态:

public class Test {
    public static void main(string[] args) {
        int a = 1;
        int b = 2;
<<<<<<< .mine
        a = 3;
||||||| .r8
=======
        a = 2;
>>>>>>> .r9
        System.out.println(a + b);
    }
}

手动处理完冲突后,使用如下命令

svn resolved Test.java

最后commit就可以了

你可能感兴趣的:(SVN学习三——冲突)