Why I get merge conflict?

人盡茶涼 提交于 2019-12-10 10:12:37

问题


I save my changes into stash. Add some code. Commit.

When I try to apply stashed changed I get merge conflict:

@@@ -847,45 -846,6 +855,53 @@@ do $$ begin RAISE NOTICE 'Move time: 20
  set local my.sys_time to '2018-08-23';

  do $$ begin
++<<<<<<< Updated upstream
 +do $$ begin RAISE NOTICE 'Move time: 2018-08-23'; end $$ language 'plpgsql';
 +set local my.sys_time to '2018-08-23';
 +
 +do $$ begin
 +--TODO: Test UPDATE when NEW.app_period is same as OLD.app_period
 +-- and NEW.app_period is intersect app_period() for some rows
 +--As update behavior should be same for rows where NEW and OLD
 +-- as different as equal (see next test after this one)
++||||||| merged common ancestors
++--TODO: Test UPDATE when NEW.app_period is same as OLD.app_period
++-- and NEW.app_period is intersect app_period() for some rows
++--As update behavior should be same for rows where NEW and OLD
++-- as different as equal (see next test after this one)
++=======
++>>>>>>> Stashed changes
  RAISE NOTICE 'Test UPDATE app_period by 2018-08-17 .. 2018-08-24, when applicatoin perio
    USING HINT =  'Row just updated. Nothing special should happen';
  end $$ language 'plpgsql';

But why? Stashed changes adds nothing to that commented TODO lines where conflict occur.


回答1:


Git doesn't silently assume two immediately adjacent blocks of text are unrelated because they often are related. In another merge your added block would be comments describing a function that was moved elsewhere or factored out.




回答2:


A conflict means, the file has been changed at least twice, in a parallel way. Like a fork:

Common ancestor -----> V1
                -----> V2

You resolve the conflict by sequencing the changes, you put them horizontally in a chronological order:

Common ancestor --> (V1 + V2) --> V3
                        |          |
                        |          |
conflicted stated after merge      new state after resolved conflict        

Which part of the file is changed doesn't matter, the way the file is changed (parallel instead sequential) creates the conflict.



来源:https://stackoverflow.com/questions/55325086/why-i-get-merge-conflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!