我使用 coding.net 创建了私有(private)存储库。
我使用 docker images alpine 和 centos。
我可以从 docker-centos 获取 git.coding.net/alphayan/orionv2.git successful
,但我无法获取 git.coding.net/alphayan/test.git
来自 docker-alpine。它返回一个错误说明:
/go/src # go get -u -v git.coding.net/alphayan/test.git
# cd .; git ls-remote https://git.coding.net/alphayan/test
fatal: could not read Username for 'https://git.coding.net': terminal prompts disabled
# cd .; git ls-remote git+ssh://git.coding.net/alphayan/test
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
# cd .; git ls-remote ssh://git.coding.net/alphayan/test
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
package git.coding.net/alphayan/test.git: cannot download, git.coding.net/alphayan/test uses insecure protocol
从centos它让我使用用户名和密码:
[root@83fc8067fc95 /]# go get -u -v git.coding.net/alphayan/test.git
Username for 'https://git.coding.net':
最后发现是git的版本问题,centos是git 1.8.3,alpine是git 2.11.0。
然后我将centos git的版本更改为2.11.0,变得与alpine一样错误。
我想我可以修改 golang 或 git 源文件来解决这个问题,
有人可以帮助我吗?想~!
最佳答案
发生此错误是因为默认情况下 go get
doesn't use terminal input .可以通过修改 git 2.3 中引入的环境变量 GIT_TERMINAL_PROMPT
来更改此行为。这就是 go get
命令在 CentOS 7 (git 1.8) 和 Alpine 3.5 (git 2.11) 中表现不同的原因。
您可以通过运行 go get
解决 git >= 2.3
中的问题,如下所示:
$ GIT_TERMINAL_PROMPT=1 go get github.com/foo/bar
Username for 'https://github.com':
如果您有多个 go get
调用,那么您可以在运行命令之前导出该环境变量:
$ export GIT_TERMINAL_PROMPT=1
$ go get github.com/foo/bar
Username for 'https://github.com':
$ go get github.com/foo/baz
Username for 'https://github.com':
关于git - Docker alpine golang go get error for coding.net private repo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42406445/