合并但覆盖Git中的更改 [英] Merging but overwriting changes in Git

查看:84
本文介绍了合并但覆盖Git中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Git中合并分支以掌握时,我经常会遇到合并冲突。有没有办法合并一个分支并只覆盖当前分支中的内容?

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 merge 命令中-X我们的参数。

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

另一方面,如果您 code> master 并想将本地分支合并到 master 中,然后@elhadi正确地说您应该使用

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

这篇关于合并但覆盖Git中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆