【已解决】warning: push.default is unset; its implicit value is changing in Git 2.0 from...

文章目录


在这里插入图片描述

异常原因

在 Linux 系统上,如果安装了新版 git(Git 2.0),在执行git push命令时,会遇到如下警告:

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)

翻译后:

警告: push.default 未设置;
在 Git 2.0 中,其隐含值从 'matching' 更改为 'simple'。
要消除此消息并在默认值更改后保持当前行为,请使用:

  git config --global push.default matching
 
要消除此消息并立即采用新行为,请使用:

  git config --global push.default simple
  
参见 'git help config' 并搜索 'push.default' 以获取更多信息。
('simple' 模式是在 Git 1.7.11 中引入的。如果您有时使用较旧版本的 Git,请使用类似的模式
'current' 而不是 'simple')

什么意思呢?简单来说:

  • git push其实有多种模式,不同的模式对应着不同的操作:今天我们简单看看上面提到的matching(匹配模式)simple(简单模式)
    • matching:这是 Git 之前默认的模式
    • simple:这是一种适合初学者的模式,并且在 Git 2.0 之后默认就是这个模式
  • 其具体区别我并不关心,什么分支匹配、什么推送拉取,先把 git 用起来,其他问题以后再说
  • matching是之前默认的,正常使用肯定是没问题的;而simple是现在默认的,我看了一下,大概就是在推送时会进行一些检查,更适合新手。我在这里还是选用之前默认的matching模式
  • 实际上这并不是一个报错,而是一个提示,你会发现在警告(warning)之后依然可以正常输入用户名和密码,因为他默认已经帮你选好了,就是simple模式,现在只是提醒你一下而已

解决方法

  • 既然我们知道了这只是一个提示信息,而并非报错,那解决起来就很简单了
  • 根据 warning 的提示,选定一个默认的推送模式即可
# 执行此命令以选择旧版 git 的默认推送模式,并消除提示信息
git config --global push.default matching
# 执行此命令以选择新版 git 的默认推送模式,并消除提示信息
git config --global push.default simple
  • 任意选择一个模式后,再进行git push指令的操作,就不会有警告了

在这里插入图片描述


如果本文未能解决你的问题,请在评论区留言讨论

END

猜你喜欢

转载自blog.csdn.net/m0_73156359/article/details/135581655