我怎样才能 git pull --rebase 但进行所有远程更改?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3438311/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:28:55  来源:igfitidea点击:

How can I git pull --rebase but taking all remote changes?

git

提问by michael

I did git fetchand then git pull --rebase. It is trying to merge changes from the remote branch to my local branch. And there are some merge conflicts. So I did a git reset --hard.

我做了git fetch然后git pull --rebase。它试图将远程分支的更改合并到我的本地分支。并且存在一些合并冲突。所以我做了一个git reset --hard.

My question is it is possible for me to ask git pull to take the remote change whenever there is a conflict?

我的问题是我可以在发生冲突时要求 git pull 进行远程更改吗?

回答by Jeff

I think what you want is this:

我想你想要的是这个:

git pull --rebase -s recursive -X ours

But it doesn't work (I'm using 1.7.0.4), even though the manpage says it should. I'm guessing this is due to the issue mentioned here.

但它不起作用(我使用的是 1.7.0.4),即使联机帮助页说它应该。我猜这是由于这里提到的问题。

Instead, you could use:

相反,您可以使用:

git pull -s recursive -X theirs

It works as expected, but you'll get a mergeinstead of a rebase.

它按预期工作,但您将获得合并而不是rebase

Also - note 'ours', rather than 'theirs' when using --rebase. From the git-rebase manpage:

另外 - 在使用 --rebase 时注意“我们的”,而不是“他们的”。从 git-rebase 联机帮助页:

[CLIP]... a rebase merge works by replaying each commit from the working branch on top of the upstream branch. Because of this, when a merge conflict happens, the side reported as ours is the so-far rebased series, starting with upstream, and theirs is the working branch. In other words, the sides are swapped. ...[CLIP]

[CLIP]... rebase 合并的工作原理是在上游分支的顶部重放来自工作分支的每个提交。正因为如此,当发生合并冲突时,报告为我们的一方是迄今为止rebase的系列,从上游开始,他们是工作分支。换句话说,双方互换。...[夹子]