gpt4 book ai didi

特定存储库的 Git 全局配置?

转载 作者:行者123 更新时间:2023-12-02 19:29:53 29 4
gpt4 key购买 nike

意思是,有类似每个 repo 部分 [repo_url] 的东西覆盖全局(不是特定 repo )选项。

[core]
filemode = false
editor = notepad
[repo "example.com/repo1.git"]
[core]
filemode = true
# editor = notepad
[repo "example.com/repo2.git"]
[core]
editor = vim
# filemode = false

在 git 中可以吗?

注意:我正在制作大量的 repos 克隆(git clone),我会在这样的全局配置中指定

最佳答案

有了 Git 2.36(2022 年第 2 季度),除了依赖本地文件夹之外,您还有另一种选择:使用“[includeIf <condition>]”的配置文件的条件包含机制学会根据URL 存储库与之交互的远程存储库。

参见 commit 399b198 , commit ed69e11 (2022 年 1 月 18 日)Jonathan Tan ( jhowtan ) .
(由 Junio C Hamano -- gitster -- merge 于 commit 13ce8f9 ,2022 年 2 月 9 日)

config: include file if remote URL matches a glob

Signed-off-by: Jonathan Tan
Acked-by: Elijah Newren

This is a feature that supports config file inclusion conditional on whether the repo has a remote with a URL that matches a glob.

Similar to my previous work on remote-suggested hooks, the main motivation is to allow remote repo administrators to provide recommended configs in a way that can be consumed more easily (e.g. through a package installable by a package manager - it could, for example, contain a file to be included conditionally and a post-install script that adds the include directive to the system-wide config file).

In order to do this, Git reruns the config parsing mechanism upon noticing the first URL-conditional include in order to find all remote URLs, and these remote URLs are then used to determine if that first and all subsequent includes are executed.
Remote URLs are not allowed to be configured in any URL-conditionally-included file.

config现在包含在其 man page 中:

hasconfig:remote.*.url:

The data that follows this keyword is taken tobe a pattern with standard globbing wildcards and twoadditional ones, **/ and /**, that can match multiplecomponents.
The first time this keyword is seen, the rest ofthe config files will be scanned for remote URLs (withoutapplying any values).
If there exists at least one remote URLthat matches this pattern, the include condition is met.

Files included by this option (directly or indirectly) are not allowedto contain remote URLs.

Note that unlike other includeIf conditions, resolving this conditionrelies on information that is not yet known at the point of reading thecondition.

A typical use case is this option being present as asystem-level or global-level config, and the remote URL being in alocal-level config; hence the need to scan ahead when resolving thiscondition.

In order to avoid the chicken-and-egg problem in whichpotentially-included files can affect whether such files are potentiallyincluded, Git breaks the cycle by prohibiting these files from affectingthe resolution of these conditions (thus, prohibiting them fromdeclaring remote URLs).

As for the naming of this keyword, it is for forwards compatibility witha naming scheme that supports more variable-based include conditions,but currently Git only supports the exact keyword described above.

config现在包含在其 man page 中:

; include only if a remote with the given URL exists (note
; that such a URL may be provided later in a file or in a
; file read after this file is read, as seen in this example)
[includeIf "hasconfig:remote.*.url:https://example.com/**"]
path = foo.inc
[remote "origin"]
url = https://example.com/git

关于特定存储库的 Git 全局配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61983894/

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