Git合并母版到开发分支是覆盖,而不是合并 [英] Git merge master into development branch is overwriting, not merging
问题描述
我遇到了一个问题,即我的主要更改完全覆盖了开发分支中的更改,而不是合并它们.
我有一个Web应用程序的管理员和一个开发分支.我目前正在开发一些功能,这些功能需要花费几周的时间才能实现,但与此同时,其他开发人员也在不断将其添加到master中.
让我以一个文件为例,functions.php
我正在dev
分支内的functions.php
文件中进行很多更改.
有时,我使用git checkout master
切换到主服务器,然后使用git pull origin master
从网上撤出.这使团队变更与我的本地开发人员保持一致.
现在,我想将这些更改引入到dev
分支的functions.php
文件中,同时保持到目前为止所做的工作.所以我签出dev
分支,然后运行git merge master
.事实是,master
分支中的功能文件完全覆盖了dev
分支中的我的功能文件.
为什么?
总结我的工作流程:
git checkout master # Move to master branch
git pull origin master # Get down local changes, all along I have been working in dev and making dev progress
git checkout dev # move to dev branch
git merge master # attempt to align team changes to my dev branch
我的文件被覆盖,不被合并.
谢谢你, 西蒙
在本地存储库或全局存储库的" .git "文件夹中检查" config "文件.
这样,如果将 notes.mergeStrategy 配置为"他们的",则您的更改将被覆盖.您只需要删除该配置,一切都会好起来.
参考:
I have a problem where my master changes are completely overwriting my changes in a development branch, instead of merging them.
I have a master and a development branch for a web application. I am currently working on features that will take a few weeks to implement, but at the same time other developers are continuously adding to master.
Let me use one file as an example, functions.php
I am making many lines of changes in the functions.php
file within the dev
branch.
Occasionally I switch to master using git checkout master
and pull from the online using git pull origin master
. This brings the team changes inline with my local dev.
Now, I want to introduce those changes into my functions.php
file in dev
branch while maintaining my work I have done thus far. So I checkout the dev
branch and I run git merge master
. The thing is, the functions file in master
branch is COMPLETELY overwriting my functions file in dev
branch.
Why?
To summarize my workflow:
git checkout master # Move to master branch
git pull origin master # Get down local changes, all along I have been working in dev and making dev progress
git checkout dev # move to dev branch
git merge master # attempt to align team changes to my dev branch
my files are overwritten, NOT merged.
Thank you, Simon
Check your "config" file inside your ".git" folder of your local repository or global.
In that, if notes.mergeStrategy is configured to "theirs", then your changes will be overwritten. You just need to remove that configuration and everything will be fine.
Ref:
这篇关于Git合并母版到开发分支是覆盖,而不是合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!