合并但覆盖 Git 中的更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14275856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Merging but overwriting changes in Git
提问by John Hunt
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?
当我将 Git 中的一个分支合并到 master 时,我经常会遇到合并冲突。有没有办法合并一个分支并只覆盖当前分支中的内容?
回答by kmkaplan
Add -X ours
argument to your git merge
command.
-X ours
向您的git merge
命令添加参数。
Say you are working in your local branch. Then you want to merge in what went in the master
:
假设您在当地分支机构工作。然后你想合并进入的内容master
:
git merge -X ours master
On the other hand if you arein master
and want to merge your local branch into master
then @elhadi rightly says you should use theirs
:
在另一方面,如果你是在master
和想你的本地分支并入master
然后@elhadi正确地说,你应该使用theirs
:
git merge -X theirs somebranch
回答by elhadi dp ?p????
To overwrite your stuff in your branch and take their work, you should make
要覆盖分支中的内容并接受他们的工作,您应该
git merge -X theirs {remote/branch} --> example:origin/master