首页 > 解决方案 > 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)

问题描述

When I try and clone a new code commit repo on my MAC I get a 403 error. I'm completely lost as to what I need to do to get 2 different accounts to work.

When I run git config -l --show-orgin I have these settings.

$ 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

my .aws/credentials file contains the following from the first account

[default]
aws_access_key_id=xxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxx

my credential-helper.sh. file contains from the first code commit account

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

I'm new to code commit and am not sure what I need to edit in order to clone the second repo.

When I do try and clone into it, I get the below error:

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

What am I missing here? We haven't set up ssh on the second account yet and are just using a username and password for the time being.

标签: gitmacosaws-codecommit

解决方案


If you want your credential-helper.sh to be used by your second repo (as described in this article), you would need to:

  • initialize an empty repo locally
  • add a local setting instructing to use that credential
  • add a remote to the remote repo
  • fetch

That is:

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

推荐阅读