git 多凭证助手

标签 git aws-codecommit

我的本​​地 git 克隆中有多个 Remote 。两个 Remote 都使用 https 连接到 git 并且需要不同的凭据。我正在使用 codecommit,因此使用 codecommit credential-helper 作为凭据。有没有一种方法可以为不同的根使用单独的凭证助手。

最佳答案

我能够将以下内容放入我的 ~/.gitconfig 中,并且我的 AWS CodeCommit 和 GitLab Remote (在同一个存储库中)能够成功获取。

[credential]
    helper = !aws --profile myusername codecommit credential-helper $@
    helper = manager
    UseHttpPath = true

我确实遇到的一个问题是:“fatal: unable to access 'https://git-codecommit.us-west-2.amazonaws.com/v1/repos/myrepo/': The requested URL返回错误:403。

当我升级我的 Windows Git 安装时,我发现这是由于位于另一个 gitconfig 中的另一个“helper = manager”造成的。我运行了“git config --list --show-origin”这样我就可以看到这是来自哪个文件(file:C:/Program Files/Git/mingw64/etc/gitconfig credential.helper=经理)。用分号 ; 注释掉这些行后,错误消失了。将该行移到我的 ~/.gitconfig 中解决了这个问题。

更新:

AWS updated their website with better information on using multiple credential helpers .这是我的 ~/.gitconfig 现在的样子:

[credential "https://git-codecommit.us-west-2.amazonaws.com"]
    helper = !aws codecommit credential-helper --profile myusername $@
    UseHttpPath = true
    ; NOTE: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-windows.html#setting-up-https-windows-credential-helper
    ; Setup username/password: https://console.aws.amazon.com/iam/home?#/users/matt?section=security_credentials
[credential]
    helper = manager

如果您使用的是 Mac 并开始在 cleaning up git credentials in OS X Keychain 上查看此答案

关于git 多凭证助手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53189190/

相关文章:

amazon-web-services - 具有多重身份验证的 AWS CodeCommit。继续获得致命的 : unable to access . 。请求的 URL 返回错误:403

amazon-web-services - Terraform:使用存储在 AWS CodeCommit 中的版本化模块

Git 为每次推送继续构建我的 'known_hosts' 文件

git 相当于 `svn export` 或 github 解决方法

git - 我的这几次 git pull --rebase 发生了什么错误 "Your local changes to the following files would be overwritten by merge"

amazon-web-services - 转到AWS Lambda:事件在哪里?

git - 错误 : waitpid for C:\Program Files (x86)\PuTTY\plink. exe 失败:没有子进程

git - 我怎样才能实现这个 Git 测试工作流程

git - IDEA 没有显示所有可以 merge 的分支

git - 如何共享在 Bluemix 中开发的 node-red 应用程序?