我如何理解 'git push --all' 中的 'all' 概念和简单的 'git push' 但 push.defaults 分别配置为 'matching'?

How do I comprehend the 'all' concept in 'git push --all' and simply 'git push' but push.defaults configured to be 'matching' respectively?

我有点难以理解问题标题的含义。基本上,git push --all(或者可能更少 git push --all <remote>)和简单的 git push 但默认为 'matching' 都引用了 'all'.

我对此进行了一些研究,但我发现的大部分内容只是分别对每个命令产生的影响,并没有找到同时考虑这两个命令的任何内容。所以我想知道他们之间是完全没有关系,还是他们同时出现时确实有重叠和相互作用。

谢谢

您的总体 git push 命令是:

git push [<options>] [<repository> [<refspec> ...]]

即有可选的选项,如--all-n--tags等。您可以使用一个或多个组合,或 none,如文档所述。所有选项都以 - 开头,以区别于其余参数。

其余参数依次为:

  • 存储库,然后
  • 参考规格。

如果你给 no 额外的参数(除了选项)你还没有提供 repository 参数,如果你只给出一个额外的参数(除了选项)你提供了 repository 但没有 refspec.

--all 标志是一种编写 refspec refs/heads/* 的方式,无需输入 refs/heads/* 作为 refspec .您不必将其作为 refspec 输入这一事实使您免于提供 repository 的义务。除了这种特殊的自由,再加上一个限制,那就是 all --all means.

(额外的限制是,如果你确实使用了 --all,你就不能 允许 使用 refspec.)

由于 --all 仅暗示一个特定的 refspec,因此可以阅读文档的其余部分 就好像 您有 运行:

git push <repository> "refs/heads/*"

对于某些 repository 参数。添加其他选项,例如 --dry-run 具有针对该选项列出的效果。

[What if] push.defaults [is] configured to be 'matching'?

如果您提供 no refspec 参数,push.defaults 设置就会生效。由于 --all 实际上 确实 提供了一个 refspec 参数,如果您使用 --all,它会被忽略。如果您使用--all并且提供refspec,您的push.default设置生效。