如果从_any_远程拉取,git会拉自动合并吗?

发布于 2024-12-27 07:26:29 字数 543 浏览 2 评论 0原文

假设我有以下配置文件

[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 run
  • merge 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱人如己 2025-01-03 07:26:29

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 do git 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 do git pull faraway master

冧九 2025-01-03 07:26:29

git pull non-default-remote 将返回,

You asked to pull from the remote 'production', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

但是如果我输入

git pull non-default-remote `git config remote.non-default-remote.fetch`

,它将自动与当前在远程上签出的内容合并,并完全忽略默认合并选项,因为我正在从非默认遥控器拉取。

git pull non-default-remote will return

You asked to pull from the remote 'production', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

But if I type

git pull non-default-remote `git config remote.non-default-remote.fetch`

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文