[英]git multiple credential helper
我的本地 git clone 中有多個遙控器。 兩個遙控器都使用 https 連接到 git 並且需要不同的憑據。 我正在使用 codecommit,因此使用 codecommit credential-helper 作為憑據。 有沒有辦法可以為不同的根使用單獨的憑證助手。
我能夠將以下內容放入我的 ~/.gitconfig 並且我的 AWS CodeCommit 和 GitLab 遙控器(在同一個 repo 中)能夠成功獲取。
[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 returned error: 403.
我發現這是由於在升級 Windows Git 安裝時位於另一個 gitconfig 中的另一個“helper = manager”。 我運行了“ git config --list --show-origin
”,以便我可以看到這是來自哪個文件( file:C:/Program Files/Git/mingw64/etc/gitconfig credential.helper=manager
)。 在用分號注釋掉這些行之后;
,錯誤消失了。 將該行移動到我的 ~/.gitconfig 中解決了這個問題。
更新:
AWS 更新了他們的網站,提供有關使用多個憑證助手的更好信息。 這是我的 ~/.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 並開始查看有關清理 OS X 鑰匙串中的 git 憑據的答案
touch ~/.username-credentials
git config --local credential.helper 'store --file ~/.username-credentials'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.