git fetch如何解决远程存储库?

时间:2018-09-18 15:57:40

标签: git

如果我运行git fetch,git如何解析远程对象?

来自git fetch doc

  

如果未指定任何远程,默认情况下,源远程为   使用,除非为当前配置了上游分支   分支。

这是否意味着它将查询branch.branchName.remote之类的git push配置值?

我不清楚...unless there’s an upstream branch configured for the current branch是什么意思。文档没有明确说明如果配置了上游,该怎么办?

有关更多详细信息:Run git push, pull and fetch without refspec argument

2 个答案:

答案 0 :(得分:0)

Fetch讨论了为当前分支配置的上游分支。

git help config并搜索“上游”会让我

   branch.<name>.merge
       Defines, together with branch.<name>.remote, the upstream branch
       for the given branch. It tells git fetch/git pull/git rebase which
       branch to merge and can also affect git push (see push.default).
       When in branch <name>, it tells git fetch the default refspec to be
       marked for merging in FETCH_HEAD. The value is handled like the
       remote part of a refspec, and must match a ref which is fetched
       from the remote given by "branch.<name>.remote". The merge
       information is used by git pull (which at first calls git fetch) to
       lookup the default branch for merging. Without this option, git
       pull defaults to merge the first refspec fetched. Specify multiple
       values to get an octopus merge. If you wish to setup git pull so
       that it merges into <name> from another branch in the local
       repository, you can point branch.<name>.merge to the desired
       branch, and use the relative path setting .  (a period) for
       branch.<name>.remote.

答案 1 :(得分:0)

正如@phd发表在评论中,以及@torek在参考链接的评论中所验证的那样,我代表他们发布答案。

如果未指定任何远程,默认情况下将使用origin远程,除非为当前分支配置了上游分支,这意味着如果为该分支配置了远程跟踪分支,则它将具有branch.<currentBranchName>.remote的配置值,它将查阅。

未明确提及时,查找存储库的行为类似于git push

相关问题