'git pull'的默认行为 [英] Default behaviour of 'git pull'

查看:265
本文介绍了'git pull'的默认行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么git pull提取所有内容,包括新创建的远程分支,但git pull origin master却不提取?

Why is that git pull pulls everything including newly created remote branches but git pull origin master does not?

我正在使用git version 2.9.3.windows.2.

推荐答案

不指定任何分支时,将使用默认设置.默认方式是获取和更新远程存储库中现有的 all 分支.

When you specify no branches, the default settings are used. The default means to fetch and update all branches existing in the remote repository.

有关详细信息,请参见文档:

See documentation for details:

git pull [options] [<repository> [<refspec>…​]]

<refspec>指定要获取的引用和要更新的本地引用.当命令行中没有<refspec>出现时,取而代之的引用是从remote.<repository>.fetch变量中读取的(请参阅git-fetch [1]).

<refspec> specifies which refs to fetch and which local refs to update. When no <refspec>s appear on the command line, the refs to fetch are read from remote.<repository>.fetch variables instead (see git-fetch[1]).

来源: https://git-scm.com/docs/git-pull

参考文档说明:

您经常通过定期重复地从同一个远程存储库中获取信息来进行交互.为了跟踪此类远程存储库的进度,git fetch允许您配置remote.<repository>.fetch配置变量.

通常这样的变量可能看起来像这样:

Typically such a variable may look like this:

[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*

上面的示例将获取origin中存在的所有分支(即,与值的左侧匹配的所有引用refs/heads/*),并更新refs/remotes/origin/*层次结构中的相应远程跟踪分支

The example above will fetch all branches that exist in the origin (i.e. any ref that matches the left-hand side of the value, refs/heads/*) and update the corresponding remote-tracking branches in the refs/remotes/origin/* hierarchy.

来源: https://git-scm.com/docs/git-fetch# CRTB

该行为是默认行为,因为它使您可以立即同步整个存储库.如果您不想一次更新所有本地分支,请使用git fetch同步存储库,并使用git merge origin/<branch>更新每个单个本地分支.

The behavior is default because it allows you to synchronize the whole repositories at once. If you don’t want to update all local branches at once, use git fetch to synchronize the repositories and git merge origin/<branch> to update each single local branch.

这篇关于'git pull'的默认行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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