Git合并冲突后,很多我没有接触的文件变成了要提交的更改 [英] After a Git merge conflict, a lot of files I didn't touch become changes to be committed

查看:38
本文介绍了Git合并冲突后,很多我没有接触的文件变成了要提交的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在一个分支中工作,进行一些更改,然后运行 ​​git merge master.我修改了其中一个文件(我知道如何处理)发生合并冲突,但出于某种原因,我没有接触过一堆文件(但在 master 中更新了)突然进入我的要提交的更改"列表.

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 总是在提交之前在暂存区组装新的提交.合并做同样的事情.在暂存区域中创建一个包含来自源分支的所有更改的新提交.如果发生冲突,此更新暂存区的过程将被中断,并将控制权交给您.这就是为什么会发生这种情况.提交后,将在源分支和目标分支作为父分支的存储库中创建合并提交".

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天全站免登陆