简体   繁体   English

合并 Master 分支、修复冲突、从合并中删除其他文件后,GIT 将我的功能分支中的文件视为最新文件

[英]After merging Master branch, fixing conflicts, removing other files from the merge, GIT is treating files in my feature branch as latest

So, trying to be proactive knowing that there were going to be some merge conflicts when merging my feature branch into Master, I went ahead and merged Master to my branch locally, fixed the conflicts, and here is the critical part---I only ended up committing the files merged from Master that I'd been working on, and removed all the rest from the commit.因此,在将我的功能分支合并到 Master 时,我试图主动知道会有一些合并冲突,我继续将 Master 合并到我本地的分支,修复了冲突,这是关键部分——我只最终提交了我一直在处理的从 Master 合并的文件,并从提交中删除了所有 rest。 Looking back of course, I shouldn't have done this... I didn't realize that it was going to treat those files that I removed as the latest changes on my feature branch.回过头来看,我当然不应该这样做......我没有意识到它会将我删除的那些文件视为我的功能分支上的最新更改。

So, attempting to do a pull request into Master, I realize that all of those files I took out of the original merge were trying to overwrite newer files in Master.因此,尝试向 Master 发出拉取请求时,我意识到我从原始合并中取出的所有文件都试图覆盖 Master 中的新文件。

This turned out to be OK, I was able to take my commit on the feature branch BEFORE the merge and clone a new branch from there.结果没问题,我能够在合并之前在功能分支上进行提交,并从那里克隆一个新分支。 So, a learning experience.所以,一个学习经验。 My question is... was there another better way to have handled this?我的问题是......是否有另一种更好的方法来处理这个问题? I'd tried reverting the merge commit but somehow it was still trying to overwrite all of those same files when I looked at merging to Master.我曾尝试恢复合并提交,但不知何故,当我考虑合并到 Master 时,它仍在尝试覆盖所有这些相同的文件。

Thanks谢谢

My question is... was there another way to do this?我的问题是......还有另一种方法可以做到这一点吗?

It depends what "this" is:这取决于“这个”是什么:

  • The correct way to deal with a merge conflict is to edit the conflicted files to resolve the conflict, add them, and say git commit .处理合并冲突的正确方法是编辑冲突的文件以解决冲突,添加它们,然后说git commit

  • The correct way to undo a bad merge is to reset hard back to the commit before the merge commit.撤消错误合并的正确方法是将硬重置回合并提交之前的提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM