【问题标题】:Git warning: push.default is unset; its implicit value is changingGit 警告:push.default 未设置;它的隐含价值正在改变
【发布时间】:2013-11-12 07:07:14
【问题描述】:

当我在 Git 中推送到远程时,我收到以下警告:

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

To **********************************
   6b9a6d2..3ab1eab  master -> master

这个警告是什么意思,应该怎么做?

【问题讨论】:

标签: git push


【解决方案1】:

我通过提供远程存储库名称和远程分支名称(已跟踪)来解决它。

在我的情况下,在 github

$ git push origin main

【讨论】:

    【解决方案2】:

    2016 年 2 月更新

    git 2.8(2016 年 3 月)删除了那个重要的警告信息

    参见Matthieu Moy (moy) commit 2f27520(2016 年 2 月 25 日)。
    (由 Junio C Hamano -- gitster -- 合并于 commit 15be621,2016 年 2 月 26 日)

    push:删除“push.default is unset”警告信息

    该警告在 2.0 转换之前很重要,并且在之后的一段时间内仍然很重要,因此新用户在他们的配置中明确获得 push.default,并且如果他们曾经使用过旧版本的 Git,也不会遇到不一致的行为。

    该警告自 1.8.0 版(2012 年 10 月)以来一直存在,因此我们可以 预计绝大多数当前的 Git 用户已经接触过 它,其中大多数已经明确设置了push.default。这 2.0(2014 年 5 月)计划从“匹配”切换到“简单”,但是 实际上只发生在 2.3(2015 年 2 月)。

    今天,警告主要是初学者看到的,没有设置他们的 push.default 配置(尚未)。对他们中的许多人来说,警告是 令人困惑,因为它谈到了他们没有学过的概念和 问他们一个他们还不能做出的选择。参见例如“Warning: push.default is unset; its implicit value is changing in Git 2.0”(1260 票赞成这个问题,1824 票赞成写作)

    完全删除警告以避免打扰初学者。那些 仍然偶尔使用旧版本的 Git 会暴露 通过这个旧版本发出警告。

    最终,没有警告的 Git 版本将得到足够的部署 并且教程将不再需要建议设置push.default


    原始答案(2014 年 3 月)

    该警告将很快在 git 2.0(2014 年第二季度)中更改,commit 289ca27commit 11037ee

    push.default 未设置;它的隐含值已改变 Git 2.0 从“匹配”到“简单”。
    要压制此消息并保持传统行为,请使用:

    git config --global push.default matching
    

    要压制此消息并立即采用新行为,请使用:

    git config --global push.default simple
    

    push.default设置为'matching'时,git会推送本地分支 到已经存在的同名远程分支。

    从 Git 2.0 开始,Git 默认采用更保守的 'simple' ”行为,只将当前分支推送到 'git pull' 用来更新当前分支的对应远程分支分支。

    在“Why is pushing to matching the default in Git?”查看更多信息。

    【讨论】:

      【解决方案3】:

      不久前我遇到了同样的问题。我解决了这个问题,

      • 首先克隆我的新分支 (UAT)
      • 然后推送到该分支 (UAT)

      【讨论】:

        【解决方案4】:

        此警告是在 Git 1.7.11 中与 simple 推送样式一起引入的。问题是当前默认值matching 可能会导致没有经验的用户在某些分支落后于其远程等效分支时强制推送,因为这些分支根本不是最新的。最终结果是他们最终会倒带分支并可能失去他们或其他人的工作。 simple 模式是作为一种新的 push.default 行为引入的,并将成为 Git 2.0 中的默认值(有望在明年年初推出)。

        新的simple 行为很像upstream 设置:如果它有一个正在跟踪的远程分支,它只会推送您当前所在的当前分支。它增加了一个额外的条件:远程分支必须与本地分支同名。

        如您所见,摆脱消息的方法是设置push.default。要获得新行为,请使用:

        git config --global push.default simple
        

        要获得 Git 的默认行为但不显示警告消息,请使用:

        git config --global push.default matching
        

        我真的建议反对使用匹配。一般来说,大多数人真的想要新的simple 行为,或upstream

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-11-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-11-05
          • 1970-01-01
          • 1970-01-01
          • 2012-08-06
          相关资源
          最近更新 更多