最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Git merge does not update target branch with all changes from source - Stack Overflow

programmeradmin1浏览0评论

I have branch "feature" with changes that I want merged into my "master" branch with the git merge feature command.

My expectation is that target branch would get overwritten with changes from source, potentially with some conflicts to resolve first. However, after resolving conflicts and manually checking the "master" branch after merge, I have found some instances where non-conflicting changes from the source were not applied, examples below.

First is an example of detected conflict that after I accepted the incoming(source) version properly appeared in the "master" branch after merge, just as I would expect

---> SOURCE VERSION
setSelectedTarget([...selectedTarget, target]);
setSelectedKey([...selectedKey, key]);
setSliderValue({...sliderValue, [target]: {value:parseFloat(list[key].OPTIONS[0].amount)}});

---> TARGET VERSION
setSelectedTarget(target);
setSelectedKey(key);
setSliderValue(parseFloat(list[key].OPTIONS[0].amount));

Now for the 2 lines that were changed in the target("feature") branch and did not get updated in "master" as I would expect during the merge.

---> TARGET VERSION
const isSelected = list[item]?.UUID === selectedTarget; ----> was on line #269

---> SOURCE VERSION
const isSelected = selectedTarget.includes(list[item]?.UUID); ----> is now on line #301

---> TARGET VERSION
<...>
<Radio ----> was on line #286
  color="primary"
<...>

---> SOURCE VERSION
<...>
<Checkbox ----> is now on line #318
  color="primary"
<...>

After the merge the "master"(target) branch retained the target version for both of those even though I expected them to be overwritten from the source. The only potential reason I can see is that due to additions of new code in the source branch the number of lines has changed and these 2 lines now had a different number, however there were other similar changes in the same merge that got moved to target from source correctly.

What is going wrong here and how do I make sure that I get all the changes from the source after the merge?

发布评论

评论列表(0)

  1. 暂无评论