git - 为什么要推送以匹配 Git 中的默认值?

标签 git

对于默认设置,Git 推送到“匹配”分支 - 具有相同名称的分支,而不是“上游”分支 - 被跟踪的分支。切换到“上游”模式对我来说会更方便,这样我就不必每次都指定我推送的分支,但我认为“匹配”是默认设置是有原因的。将设置设置为“匹配”而不是“上游”设置会解决任何问题吗?

最佳答案

如“Warning: push.default is unset; its implicit value is changing in Git 2.0”中所述:

matching means git push will push all your local branches to the ones with the same name on the remote. This makes it easy to accidentally push a branch you didn't intend to.

这不是最佳实践:您不应该推送所有您的分支。
它们中的大多数可以是用于测试或内部开发的私有(private)分支。

simple (Git 2.0 default) 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.

默认情况下,它会推送您正在处理的分支,前提是该分支存在于远程端且名称相同(或者如果您明确创建它)。

您可以在“[git push - 默认行为?]。2”中找到有关该策略更改的更多讨论。

我在“git - push current vs. push upstream (tracking)”中描述了其他政策。


新的默认策略现在 merge 到主(commit 289ca27)并声明它是commit 11037ee中的新默认值:

We promised to change the behavior of lazy "git push [there]" that does not say what to push on the command line from "matching" to "simple" in Git 2.0.

This finally flips that bit.

关于git - 为什么要推送以匹配 Git 中的默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21772279/

相关文章:

c - 如何检索所有对象 ID?

c# - File.WriteAllText 正在根据 Git 更改我的文件的开头

git - 从本地计算机在远程服务器上创建git repo

git - 恢复删除的子模块

git - 什么样的目录结构对 DVCS(例如 git)有意义?

git - git如何统计每个文件被修改了多少次?

git - 我怎样才能从远程标签 rebase 到本地主人

cPanel 上的 Github Private Repo 连接问题

android - 初始化 repo

git - MINGW32 GIT 客户端无法连接 Bonobo GIT 服务器