git多凭证助手 [英] git multiple credential helper

查看:132
本文介绍了git多凭证助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地git克隆中有多个遥控器。两个遥控器都使用https连接到git,并且需要不同的凭据。我正在使用codecommit,因此使用codecommit凭据帮助器获取凭据。有没有办法可以为不同的根使用单独的凭据帮助程序。

I have multiple remotes in my local git clone. Both of the remotes are using https to connect to git and need different credentials. I am using codecommit and hence the codecommit credential-helper for credentials. Is there a way I can use separate credential helper for different roots.

推荐答案

我能够在我的〜/中添加以下内容.gitconfig以及我的AWS CodeCommit和GitLab遥控器(在同一存储库中)都能够成功获取。

I was able to put the following in my ~/.gitconfig and my AWS CodeCommit and GitLab remotes (in the same repo) were able to successfully fetch.

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

我确实遇到的一个问题是:致命:无法访问'https://git-codecommit.us-west-2.amazonaws.com/v1/ repos / myrepo /':请求的URL返回错误:403。

One issue I did have though was: "fatal: unable to access 'https://git-codecommit.us-west-2.amazonaws.com/v1/repos/myrepo/': The requested URL returned error: 403.

我发现这是由于位于其中的另一个 helper = manager升级Windows Git安装时,另一个gitconfig运行了 git config --list --show-origin ,这样我就可以看到该文件来自( file:C:/ Program Files / Git / mingw64 / etc / gitconfig credential.helper = manager )。在注释行之后用分号; 删除,错误消失了。将那条线移到我的〜/ .gitconfig中即可解决问题。

I discovered this was due to another "helper = manager" located in another gitconfig when I upgraded my Windows Git install. I ran "git config --list --show-origin" so that I could see which file this was from (file:C:/Program Files/Git/mingw64/etc/gitconfig credential.helper=manager). After commenting the lines out with semicolon ;, the error disappeared. Moving that line into my ~/.gitconfig resolved the issue.

更新:

AWS更新了其网站,其中提供了有关使用多个凭证帮助程序的更好信息。这是我的〜/ .gitconfig现在的样子:

AWS updated their website with better information on using multiple credential helpers. Here is what my ~/.gitconfig looks like now:

[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,并开始在清理OS X钥匙串中的git凭据

If you are on a Mac and start see this answer on cleaning up git credentials in OS X Keychain

这篇关于git多凭证助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆