Merging but overwriting changes in Git

拥有回忆 提交于 2019-12-03 18:22:08

问题


When I merge a branch in Git to master I often get merge conflicts. Is there a way to merge a branch and just overwrite the stuff in the current branch?


回答1:


Add -X ours argument to your git merge command.

Say you are working in your local branch. Then you want to merge in what went in the master:

git merge -X ours master

On the other hand if you are in master and want to merge your local branch into master then @elhadi rightly says you should use theirs:

git merge -X theirs somebranch



回答2:


To overwrite your stuff in your branch and take their work, you should make

git merge -X theirs {remote/branch} --> example:origin/master


来源:https://stackoverflow.com/questions/14275856/merging-but-overwriting-changes-in-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!