git merge< branch>之间的区别和git merge origin< branch> [英] Difference between git merge <branch> and git merge origin <branch>

查看:176
本文介绍了git merge< branch>之间的区别和git merge origin< branch>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是git merge origin branchgit merge origin/branch

git merge <branch>将合并到工作分支中.因此,我们需要指定分支的源".它可以是本地可用的origin/<branch>或本地工作分支heads/branch.

git merge <branch> merges the into the working branch. And so we need to specify the "source" of the branch. It can be a locally available origin/<branch> or the local working branch heads/branch.

但是origin有什么需要?与git pull不同,我们不需要指定要从中获取远程资源.据我了解,合并操作是本地操作.

But what's the need for origin? Unlike git pull we don't need to specify which remote source to fetch the from. A merge operation, to my understanding, is a local operation.

推荐答案

git pull命令使您可以指定用于获取的默认远程分支,以及默认目标本地分支作为合并目标.这样做是有道理的,因为通常一个给定的本地分支在远程上只会有一个上游.

The git pull command lets you specify a default remote branch to be used for fetching, as well as the default target local branch as the merge target. It makes sense to do this, because typically a given local branch will only have one upstream on the remote.

另一方面,git merge操作可能是在 any 源分支(以您的本地分支为目标)下发生的.因此,允许定义要在合并中使用的默认源分支的意义不大.

On the other hand, the git merge operation could be happening with any source branch, with your local branch as the target. Therefore, it makes less sense to allow for defining a default source branch to be used in merging.

当您要更新远程分支的本地版本时,当然可以使用默认源分支进行合并的一个实例是git pull.但是,这种合并方案实际上是git pull的一部分,通常不会单独进行合并.

The one instance where a default source branch for merging would make sense is of course git pull, when you want to update your local version of the remote branch. But, this merge scenario is actually part of git pull, and usually is not done a separate merge.

这篇关于git merge&lt; branch&gt;之间的区别和git merge origin&lt; branch&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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