gpt4 book ai didi

git - `~/.gitconfig` 语法是否需要空格、制表符或两者之一来缩进?

转载 作者:行者123 更新时间:2023-12-05 04:04:36 26 4
gpt4 key购买 nike

我正在编辑我的 ~/.gitconfig 并注意到有混合的制表符/空格。通常混合使用制表符/空格是不好的,但是当我试图查找文档以了解允许的语法要求时,我找不到答案。

~/.gitconfig 语法是否需要空格、制表符或两者之一来缩进?

这在 git-config 文档的什么地方有解释?

最佳答案

不,.gitconfig 不需要空格和/或制表符来缩进。

每行开头的空格将被忽略,这意味着您可以自由缩进或不缩进、空格或制表符,这无关紧要。

只有值内的空白被逐字保留,其他空白被忽略。

因此,请随意使用您认为合适的空格和/或制表符,或者完全删除缩进。

请注意,gitconfig 语法允许您在下一行继续行,这些行内的空格将被保留,但这里:

 name = value
^ ^ ^ ^

所有的空白都被有效地忽略了,而这里:

name = value1 value2
^

这是保留的。


为了回答您的问题,并非所有这些都得到了完整的记录,因此其中一些行为是通过观察得出的,但大部分是在 git-config 上发现的。文档页面:

The syntax is fairly flexible and permissive; whitespaces are mostly ignored. The # and ; characters begin comments to the end of line, blank lines are ignored.

Leading whitespaces after name =, the remainder of the line after the first comment character # or ;, and trailing whitespaces of the line are discarded unless they are enclosed in double quotes. Internal whitespaces within the value are retained verbatim.

关于git - `~/.gitconfig` 语法是否需要空格、制表符或两者之一来缩进?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52388331/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com