簡體   English   中英

go get 似乎忽略了 gitconfig

[英]go get appears to be ignoring gitconfig

尋求一點幫助。 我在遠程 gitlab 實例上托管了一個私有倉庫,我應該能夠訪問它。 但無論我嘗試什么, go get似乎都在嘗試使用 https 而不是 SSH。 我可以git clonegit fetch etc ,沒有任何問題。 但是,一旦我使用go get ,它就會失敗。

我做的第一件事是添加: git config --global --add url."git@git.mydomain.io:".insteadOf "https://git.mydomain.io/"

然后我 cd 到我的項目目錄並運行 go 獲取,它嘗試通過 HTTPS 進行身份驗證失敗,並顯示“致命:無法讀取'https://git.my.domain'的用戶名:終端提示已禁用”:

PS C:\Users\User\go\src\git.my.domain\ps\wk\collector> go get            
go: downloading git.my.domain/ps/mqtt v0.0.0-20220903204713-6f195510d46e
go: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: verifying module: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: reading https://sum.golang.orglookup/git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: 404 Not Found
        server response:
        not found: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/v
cs/3a728c5d3b6137ea441372540f3e7bc1390c001346a70d5b7df3eda6d5e7316d: exit status 128:
                fatal: could not read Username for 'https://git.my.domain': terminal prompts disabled
        Confirm the import path was entered correctly.
        If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
go: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: verifying module: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: reading https://sum.golang.org/lookup/git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: 404 Not Found
        server response:
        not found: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/v
cs/3a728c5d3b6137ea441372540f3e7bc1390c001346a70d5b7df3eda6d5e7316d: exit status 128:
                fatal: could not read Username for 'https://git.my.domain': terminal prompts disabled
        Confirm the import path was entered correctly.
        If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
go: module git.my.domain/ps/wk/collector/service: git ls-remote -q origin in C:\Users\User\go\pkg\mod\cache\vcs\7d02e96755cff57eaec3323ab70c24a12ab19
eac805790ed1220d62b15affcf8: exit status 128:
        remote:
        remote: ========================================================================
        remote:
        remote: The project you were looking for could not be found.
        remote:
        remote: ========================================================================
        remote:
        fatal: Could not read from remote repository.

        Please make sure you have the correct access rights
        and the repository exists.
go: module git.my.domain/ps/wk/collector/service/service: git ls-remote -q origin in C:\Users\User\go\pkg\mod\cache\vcs\7d02e96755cff57eaec3323ab70c2
4a12ab19eac805790ed1220d62b15affcf8: exit status 128:
        remote:
        remote: ========================================================================
        remote:
        remote: The project you were looking for could not be found.
        remote:
        remote: ========================================================================
        remote:
        fatal: Could not read from remote repository.

        Please make sure you have the correct access rights
        and the repository exists.

我要瘋了。 我已經嘗試了讓go get使用 SSH 的所有組合:

git config --global --add url."git@git.mydomain.io/".insteadOf "https://git.mydomain.io/"

git config --global --add url."git@git.mydomain.io".insteadOf "https://git.mydomain.io"

git config --global --add url."ssh://git@git.mydomain.io:".insteadOf "https://git.mydomain.io/"
...

我有什么特別的事情要做嗎? 我只是不明白為什么go get使用 HTTPS 而 git 命令似乎正確使用 Z76250353E6C98AC78A9AC

=======================

編輯:好的,更多的過期讓我意識到這是有效的:

[url "ssh://git@git.mydomain.io"] insteadOf = https://git.mydomain.io/

因為我收到一個新錯誤:

        ssh: Could not resolve hostname git.mydomain.iops: Name or service not known
        fatal: Could not read from remote repository.

但是一旦我添加了斜杠來修復它,我就會回到 HTTPS 錯誤。 在 ssh 之前發生的 HTTPS 是否明智?

嘗試直接修改您的~/.gitconfig文件,確保您的私人倉庫的條目如下所示

[url "git@gitlab.com:"] insteadOf = https://gitlab.com

也許與語法有關。

還將 url (沒有https:// )添加到您的$GONOPROXY中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM