git 版本控制 git push.default 的设置

本文详细解释了Git中push.default配置选项的作用及不同设置的影响。包括matching、simple和current三种模式的区别,帮助开发者理解如何避免意外推送分支。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在新装的 ubuntu 的笔记本上搭建开发环境,新装的软件也都是比较新的,在使用 git 的时候,就出现了一些新情况,以前没有看见的。虽然说是警告,作为一个名程序员,不应该 care warning 的,但是作为一名处女座的程序员,实在是不能容忍这个该死的 warning 总是出现在我提交代码的时候。于是看一下。转载请注明来自:http://www.binkery.com/

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:转载请注明来自:http://www.binkery.com/

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:转载请注明来自:http://www.binkery.com/

git config --global push.default simple

When push.default is set to 'matching', git will push local branches to the remote branches that already exist with the same name. 使用 matching 的话,就可能出现这种情况,你在当前某个分支工作,做一半的时候,来了个紧急的任务,你切换到其他分支去工作了,当你修改完代码后提交代码,这个时候可能会把其他分支的代码一块提交了,这可能不是你想要的。为了谨慎起见,我一直都是使用 simple 的方式提交,哪怕多出一些工作量,也要谨慎。转载请注明来自:http://www.binkery.com/

In Git 2.0, Git will default to the more conservative 'simple' behavior, which only pushes the current branch to the corresponding remote branch that 'git pull' uses to update the current branch.转载请注明来自:http://www.binkery.com/

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)转载请注明来自:http://www.binkery.com/

其实就是一个问题,push 的时候,提交多少个分支的代码。是当前的分支呢?还是所有本地和服务器名字一样的分支? simple 是 push 当前分支,也就是通过 git pull 命名更新的分支,而 matching 提交的是名字一样的分支,只有服务器存在名字一样的,都提交。转载请注明来自:http://www.binkery.com/

另外,还有个 current 的模式,如果 git 版本比较早的话,可以使用 current 模式。

转载于:https://www.cnblogs.com/arenouba/p/5441062.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值