英文:
Get a private repository from AWS codecommit using HTTPS GRC
问题
我正在尝试导入位于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
命令时,我可以正常获取分支和标签的信息。
我查看了这个主题,但在那种情况下,使用的是SSH协议而不是HTTP GRC。也许从私有存储库导入模块的唯一方法是通过SSH?
英文:
I'm trying to import a module located in AWS codecommit. To clone the repository I'm using HTTPS GRC (Git Remote Codecommit) method, which uses Google Suite credentials to access AWS console.
The command I use to clone the repository is:
git clone codecommit::us-west-2://my-module
The remote module's go.mod
file contains this:
module git-codecommit.us-west-2.amazonaws.com/my-module.git
I tried to achieve my goal configuring Git like this:
git config --global url."codecommit::us-west-2://".insteadOf "https://git-codecommit.us-west-2.amazonaws.com/"
Setted GOPRIVATE:
go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com/my-module.git
And then getting the repository:
go get -x git-codecommit.us-west-2.amazonaws.com/my-module.git
but I get this output (and the execution gets stuck):
cd.
git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module
I would like to mention that when I execute the git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module
command manually I get the information of the branches and tags without problems.
I checked this topic but in that case SSH protocol is used instead of HTTP GRC. Maybe the only way to import a module from a private repository is via SSH?
答案1
得分: 4
最后找到了解决方案:
设置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
英文:
Finally found the solution:
Set Git credential helper:
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
Set GOPRIVATE env var:
go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com
In MacOS, disable keychain for Git:
Comment helper = osxkeychain
in the file containing that value (run git config -l --show-origin | grep credential
to find the target file)
Run go get:
go get git-codecommit.us-west-2.amazonaws.com/v1/repos/my-module.git
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论