【问题标题】:I already have 1 code commit account set up, how do I set up a second code commit account? (I'm getting a clone error on the second account)我已经设置了 1 个代码提交帐户,如何设置第二个代码提交帐户? (我在第二个帐户上收到克隆错误)
【发布时间】:2020-10-21 10:10:07
【问题描述】:

当我尝试在我的 MAC 上克隆一个新的代码提交 repo 时,我收到 403 错误。我完全不知道我需要做什么才能让 2 个不同的帐户正常工作。

当我运行 git config -l --show-orgin 我有这些设置。

$ git config -l --show-origin
file:/Library/Developer/CommandLineTools/usr/share/git-core/gitconfig   credential.helper=osxkeychain
file:/Users/username/.gitconfig       user.email=firstnamelastname@company.com

我的 .aws/credentials 文件包含来自第一个帐户的以下内容

[default]
aws_access_key_id=xxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxx

我的凭证-helper.sh。文件包含来自第一个代码提交帐户

echo username="[xxxxxxxx]"
echo password="[xxxxxxxxxxxxx]"

我是代码提交的新手,不确定我需要编辑什么才能克隆第二个 repo。

当我尝试克隆到它时,我收到以下错误:

fatal: unable to access 'https://git-codecommit.xxxxxxxxx/v1/repos/xxxxxxxx/': The requested URL returned error: 403

我在这里缺少什么?我们还没有在第二个帐户上设置 ssh,暂时只是使用用户名和密码。

【问题讨论】:

    标签: git macos aws-codecommit


    【解决方案1】:

    如果您希望您的 credential-helper.sh 被您的第二个 repo 使用(如 this article 中所述),您需要:

    • 在本地初始化一个空仓库
    • 添加指示使用该凭据的本地设置
    • 将遥控器添加到远程仓库
    • 获取

    即:

    git init .
    git config credential.helper "/bin/bash /full/path/to/credential-helper.sh"
    git remote add origin https://git-codecommit.xxxxxxxxx/v1/repos/xxxxxxxx/
    git fetch
    git switch master
    

    【讨论】:

    • 两个repos都可以使用shell文件吗? (2 个不同的帐户?)我不想将文件从第一个 repo 切换到第二个 repo,而是将它用于两者。
    • @cauthon 最好将这些文件分开,以避免任何帐户混淆。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-19
    • 2014-08-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    相关资源
    最近更新 更多