异常排查 | warning: push.default is unset; its implicit value is changing in Git 2.0

在这里插入图片描述

发现问题

今日在Linux环境下使用使用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
  • 说是warning: push.default is unset; its implicit value is changing in Git 2.0push.default未设置,因为是头一次在Linux环境下使用git上面云端,所以就想到可能是有什么东西没有配置
  • 阅读了一下给出的错误提示,应该是可以使用我下面框起来的两行命令,所以就在命令行执行了一下这两行命令

在这里插入图片描述

  • 然后再去【git push】的时候就不会出现上述的错误警告了,那说明这个问题已经得到解决了,但非常疑惑这是为什么,于是就查询了一些资料去研究了一下

资料查询

StackOverFlow
Linux社区问答网站


simple means git push will push only the current branch to the one that git pull would pull from, and also checks that their names match. This is a more intuitive behavior, which is why the default is getting changed to this.

匹配意味着【git push】会将所有本地分支推送到远程上同名的分支。这使得你很容易不小心推到你不想推的树枝

simple means git push will push only the current branch to the one that git pull would pull from, and also checks that their names match. This is a more intuitive behavior, which is why the default is getting changed to this

simple意味着将只将当前分支推送到git pull将从中拉出的分支,并检查它们的名称是否匹配。这是一个更直观的行为,这就是为什么默认值会更改为这个

  • 这个警告是在Git 1.7.11中引入的,同时还有simple推送方式.问题是当前的默认值matching会导致没有经验的用户在某些分支机构位于其远程等价物后面时强制推送,因为分支机构根本不是最新的.最终的结果是他们最终倒闭分支并可能失去他们的工作或其他人的工作.
  • 该simple模式是作为一种新push.default行为引入的,并将成为Git 2.0中的默认模式

解决问题

解决方案1:使用新版的shell

  • 关闭运行旧版本git的shell并使用新版本

解决方案2:修改默认设置

  • 摆脱消息的方法是设置push.default.要获得新行为,请使用:
git config --global push.default simple
  • 要获取Git的默认行为但没有警告消息,请使用:
git config --global push.default matching

———————————————
2023年2月24日晚11点。遇此问题,顺手记录

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

烽起黎明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值