【问题标题】:What is the difference between git fetch and git fetch origin [duplicate]git fetch 和 git fetch origin 有什么区别[重复]
【发布时间】:2018-04-11 01:51:57
【问题描述】:

这两个命令有什么区别?

git fetch

git fetch origin

【问题讨论】:

    标签: git gitlab


    【解决方案1】:

    这比链接的答案更简单(这实际上是关于使用git fetch origingit fetch origin mastergit fetch origin master:master 更新的名称;并且对于非常旧版本的Git,该答案略有不同,因为它的行为在 Git 版本 1.8.4 中有所改变)。

    引用the git fetch documentation

    当没有指定远程时,默认使用origin 远程,除非为当前分支配置了上游分支。

    换句话说:

    git fetch
    

    完全一样如下:

    git fetch origin
    

    除非当前分支的上游设置引用了origin 以外的远程。因此,例如,如果当前分支是rumpelsnakeskin,而rumpelsnakeskin 的上游是habitat/rumpelsnakeskin,那么git fetch 表示git fetch habitat。但是如果当前分支是 master 并且它的上游是 origin/master 或者根本没有设置,那么 git fetch 意味着 git fetch origin

    【讨论】:

      【解决方案2】:

      git fetch 获取所有遥控器。 但是在git fetch origin 中使用origin 指定需要获取的remote

      see this for reference

      【讨论】:

      • 这是不正确的。您可以使用git fetch --all 获取所有遥控器,也可以使用git remote update 和/或远程组。
      • 感谢您的澄清
      猜你喜欢
      • 2011-02-10
      • 2014-02-27
      • 2014-03-31
      • 2022-06-14
      • 2017-06-30
      • 2021-08-17
      • 2011-03-22
      • 2016-11-10
      相关资源
      最近更新 更多