在Git合并冲突之后,我没有碰到的很多文件都变成了承诺 [英] After a Git merge conflict, a lot of files I didn't touch become changes to be committed

查看:314
本文介绍了在Git合并冲突之后,我没有碰到的很多文件都变成了承诺的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在一个分支中工作,做一些改动,并运行 git merge master 。我在其中一个修改过的文件(我知道该如何处理)上遇到合并冲突,但出于某种原因,我做了一堆文件而不是触摸(但它在主文件中已更新)突然进入我的要提交更改列表。



这是为什么?我该如何解决这个问题?我不希望任何这些非我所做的更改都被提交。

解决方案

当您尝试合并时,所有可以自动合并的文件(例如,在本地分支中没有任何更改但在源分支上已经修改的文件)会自动合并并暂存。无法自动合并的文件在您的工作区使用冲突标记更新,您必须修复它们。



在提交之前,Git总是在暂存区中组装新的提交。合并做同样的事情。来自分支的所有更改的新提交将在暂存区域中创建。如果发生冲突,这个更新暂存区域的过程将被中断,并向您进行控制。这就是为什么会发生。一旦提交,将在源和目标分支都作为父项的存储库中创建合并提交。



至于我不希望任何这些非我所做的更改得到承诺,为什么你要做一个合并,你想要改变吗?

So I'm working in a branch, make some changes, and run git merge master. I get a merge conflict on one of the files I modified (which I know how to deal with), but for some reason, a bunch of files I did not touch (but which got updated in master) suddenly enter my list of "Changes to be committed".

Why is this? And how do I fix this? I don't want any of these not-by-me changes to get committed.

解决方案

When you attempt a merge, all files that can be automatically merged (e.g. where you don't have any changes in your local branch but which have been modified on the source branch), are automatically merged and staged. Files which could not be automatically merged are updated in your working area with conflict markers and you have to fix them.

Git always assembles new commits in the staging area before committing them. The merge does the same thing. A new commit with all the changes from the source branch is created in the staging area. In case of a conflict, this process of updating the staging area is interrupted and control is given to you. That's why this happens. Once you commit, a "merge commit" will get created in the repository that has both the source and target branches as parents.

As for " I don't want any of these not-by-me changes to get committed.", why did you do a merge at all if you don't want any changes?

这篇关于在Git合并冲突之后,我没有碰到的很多文件都变成了承诺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆