【问题标题】:Get a private repository from AWS codecommit using HTTPS GRC使用 HTTPS GRC 从 AWS codecommit 获取私有存储库
【发布时间】:2021-10-26 21:33:54
【问题描述】:

我正在尝试导入位于 AWS codecommit 中的模块。为了克隆存储库,我使用 HTTPS GRC (Git Remote Codecommit) 方法,该方法使用 Google Suite 凭据访问 AWS 控制台。

我用来克隆存储库的命令是:

git clone codecommit::us-west-2://my-module

远程模块的go.mod 文件包含以下内容:

module git-codecommit.us-west-2.amazonaws.com/my-module.git

我试图像这样配置 Git 来实现我的目标:

git config --global url."codecommit::us-west-2://".insteadOf "https://git-codecommit.us-west-2.amazonaws.com/"

设置 GOPRIVATE:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com/my-module.git

然后获取存储库:

go get -x git-codecommit.us-west-2.amazonaws.com/my-module.git

但是我得到了这个输出(并且执行被卡住了):

cd.
git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module

我想提一下,当我手动执行git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module 命令时,我可以毫无问题地获取分支和标签的信息。

我检查了this topic,但在这种情况下使用 SSH 协议而不是 HTTP GRC。也许从私有存储库导入模块的唯一方法是通过 SSH?

【问题讨论】:

  • 您使用 http-grc 协议的动机是什么?您是否真的按照其他问题的答案中的建议尝试在 repo-url 末尾使用 .git ? (对我来说,无论哪种方式,.git 都不是必需的)。 git config --global url.xxx 似乎是一个错误,因为你为什么要为所有 repos / pprojects 设置这个设置?
  • 在我的公司中,出于安全原因,我们使用 https-grc 而不是 SSH。是的,我在最后尝试使用 .git:go get -x git-codecommit.us-west-2.amazonaws.com/my-module.git。 git config --global 似乎对于获取不使用标准 HTTPS 协议的存储库是必要的,因为我在其他来源中读到。事实上,我不能 go get codecommit::us-west-2://my-module 因为 go get 命令不允许使用像“:”这样的字符

标签: go aws-codecommit go-modules go-get


【解决方案1】:

终于找到解决办法了:

设置 Git 凭证助手:

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

设置 GOPRIVATE 环境变量:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com

在 MacOS 中,禁用 Git 钥匙串:

在包含该值的文件中注释helper = osxkeychain(运行git config -l --show-origin | grep credential 以查找目标文件)

运行 go get:

go get git-codecommit.us-west-2.amazonaws.com/v1/repos/my-module.git

【讨论】:

  • 你是圣人。谢谢你帮了我很多!
猜你喜欢
  • 2020-06-03
  • 2018-06-07
  • 2022-12-21
  • 2018-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-17
相关资源
最近更新 更多