如果从_any_远程拉取,git会拉自动合并吗?
假设我有以下配置文件
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "origin"]
url = ssh://origin.com
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "faraway"]
url = ssh://faraway.com
fetch = +refs/heads/*:refs/remotes/faraway/*
,如果我执行 git checkout master; git pull origin 然后:
fetch
将运行merge
将把获取的分支与我当前的分支合并。
如果我运行 git checkout master; git pull faraway,那么 git-merge 会合并任何东西吗?毕竟,我是从与配置的远程不同的远程拉取的。
let's say I have the following config file
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "origin"]
url = ssh://origin.com
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "faraway"]
url = ssh://faraway.com
fetch = +refs/heads/*:refs/remotes/faraway/*
if I do git checkout master; git pull origin
then:
fetch
will runmerge
will merge the fetched branch with my current branch.
If I run git checkout master; git pull faraway
, then will git-merge
merge anything? After all, I am pulling from a different remote than the configured remote.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
remote = origin
指定当您在分支中时拉取(实际上是获取)的默认行为。因此,当您执行 git pull 时,远程是原点(这也是默认的,即即使未指定远程,它也会从原点拉取。如果指定了其他某个远程,则该远程将已被获取。)当你执行
git pull faraway
时,它将获取faraway分支,但不会将其合并(因为faraway不是配置的远程)它在当前分支主控中,除非你执行<代码>git拉远方大师The
remote = origin
specifies the default behavior for pull (fetch actually) when you are in the branch. So when you dogit pull
, the remote is origin ( which is also the default i.e even if the remote was not specified, it would have pulled from origin. If some other remote was specified, that remote would have been fetched.)And when you do
git pull faraway
, it will fetch the faraway branches but will not merge ( as faraway is not the configured remote) it in the current branch master, unless you dogit pull faraway master
git pull non-default-remote
将返回,但是如果我输入
,它将自动与当前在远程上签出的内容合并,并完全忽略默认合并选项,因为我正在从非默认遥控器拉取。
git pull non-default-remote
will returnBut if I type
then it will automatically merge with whatever is currently checked out on the remote and completely ignore the default merge option since I'm pulling from a non-default remote.