gpt4 book ai didi

Git不要求凭据

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

我正在尝试使用以下命令获取 git 存储库

git fetch -o origin (https://git.mydomain.com/path/to/repo.git)

然而它导致
fatal: No such file or directory

如果我将凭据添加到 url 中:
git fetch -o origin (https://username:password@git.mydomain.com/path/to/repo.git)

它就像一个魅力

如何在没有凭据的情况下获取 url 工作?

编辑:由于命令是 npm install 的一部分,这里是示例命令,您可以在它之外复制问题..
git clone -o origin https://git.mydomain.com/path/to/repo.git

最佳答案

这应该使用 git credential storage 进行管理,如 GCM(Git 凭据管理器)for WindowsMac/Linux .
如果您对多个 URL 拥有相同的凭据,使用 Git 2.26(2020 年第一季度),用于凭据子系统的配置元素现在可以 使用通配符模式指定条目适用于哪一组 URL。
commit 46fd7b3 , commit 82eb249 , commit 588c70e , commit 732f934 , commit 3fa0e04 (2020 年 2 月 20 日)作者:brian m. carlson (``) .
(由 Junio C Hamano -- gitster --commit 2cbb058 中 merge ,2020 年 3 月 5 日)

credential: allow wildcard patterns when matching config

Signed-off-by: brian m. carlson

In some cases, a user will want to use a specific credential helper for a wildcard pattern, such as https://*.corp.example.com.

We have code that handles this already with the urlmatch code, so let's use that instead of our custom code.

Since the urlmatch code is a superset of our current matching in terms of capabilities, there shouldn't be any cases of things that matched previously that don't match now.

However, in addition to wildcard matching, we now use partial path matching, which can cause slightly different behavior in the case that a helper applies to the prefix (considering path components) of the remote URL.

While different, this is probably the behavior people were wanting anyway.

Since we're using the urlmatch code, we need to encode the components we've gotten into a URL to match, so add a function to percent-encode data and format the URL with it.

We now also no longer need to the custom code to match URLs, so let's remove it.

Additionally, the urlmatch code always looks for the best match, whereas we want all matches for credential helpers to preserve existing behavior.

Let's add an optional field, select_fn, that lets us control which items we want (in this case, all of them) and default it to the best-match code that already exists for other users.



对于 Git 2.27(2020 年第二季度),用于 credential.<URL>.<variable> 的解析器配置已更新以处理 <URL> s 与 ' / '在他们正确。
commit b44d011 (2020 年 4 月 27 日)作者: brian m. carlson ( bk2204 ) .
(由 Junio C Hamano -- gitster --commit fd65fc3 中 merge ,2020 年 5 月 5 日)

credential: fix matching URLs with multiple levels in path

Reported-by: Ilya Tretyakov
Signed-off-by: Carlo Marcelo Arenas Belón
Signed-off-by: brian m. carlson

46fd7b3900 ("credential: allow wildcard patterns when matching config", 2020-02-20, Git v2.26.0-rc0 -- merge listed in batch #0) introduced support for matching credential helpers using urlmatch.

In doing so, it introduced code to percent-encode the paths we get from the credential helper so that they could be effectively matched by the urlmatch code.

Unfortunately, that code had a bug: it percent-encoded the slashes in the path, resulting in any URL path that contained multiple levels (i.e., a directory component) not matching.

We are currently the only caller of the percent-encoding code and could simply change it not to encode slashes.

However, we still want to encode slashes in the username component, so we need to have both behaviors available.

So instead, let's add a flag to control encoding slashes, which is the behavior we want here, and use it when calling the code in this case.

Add a test for credential helper URLs using multiple slashes in the path, which our test suite previously lacked, as well as one ensuring that we handle usernames with slashes gracefully.

Since we're testing other percent-encoding handling, let's add one for non-ASCII UTF-8 characters as well.

关于Git不要求凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25640955/

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