24

I have an AWS account. I created a repository in us-east-1 region. When I try to access it from my Mac's terminal I get an error fatal: repository 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/demo/' not found. I was able to access this repository using SourceTree GIT client.

I create another repository in California region and I was able to access that repository from the terminal itself.

Why my Mac's terminal can't find repositories in a particular AWS region?

ujjwal garg
  • 711
  • 3
  • 8
  • 18

8 Answers8

37

I followed the link that both VonC and Uzair mentioned and I was able to get to the CLI git command to work after just entering:

git config --global credential.UseHttpPath true

Thanks VonC. PS: Make sure you have a current version of git installed. CodeCommit supports Git versions 1.7.9 and later.

Michael Behrens
  • 911
  • 10
  • 8
13

Use the following commands

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
Ramesh
  • 131
  • 1
  • 2
  • 1
    Can you explain why this works? I think it's something to related with the [AWS CLI profiles](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) – William Ardila Aug 03 '21 at 22:09
10

If you are using AWS profiles, then adding credential helper without profile, will use the default profile of your AWS CLI setup. To make sure you are using the same profile/AWS account where your CodeCommit repository is located, you need to specify profile in credential-helper use like this:

git config --global credential.helper '!aws --profile HERE_YOUR_CLI_PROFILE_NAME codecommit credential-helper $@'

Maksim Luzik
  • 5,863
  • 4
  • 36
  • 57
5

Check if SourceTree has a Git config different from your Git command line: this answer points out to setting:

[credential]
helper = /usr/local/bin/aws codecommit credential-helper $@
UseHttpPath = true

Ie: The credential helper for AWS might not have been set for that particular repository in command line, while the Git used by SourceTree (which can be an embedded one) would be correctly set.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

Watch out: this error can be returned even if the repository is found, but the credentials provided are not correct.

In my case, since i have 2 aws accounts, i was using profile A to access account of profile B, and this gave me this error.

BabaNew
  • 884
  • 1
  • 13
  • 27
0

I agree with first trying out VonC's suggestion above. Here's the link for setting up the credential helper for further reference:

https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html#setting-up-https-unixes-credential-helper

Uzair Khan
  • 169
  • 1
  • 5
0

If you have used a CodeCommit repository in another AWS account the credentials for the first account can be cached on your computer, and as a result git is looking for the CodeCommit repo in the first account.

To solve this in Windows open Credential Manager (hit start, type credential), find your cached credentials, then delete them. It's also possible that the git credential manager or another credential manager is being used, which is worth investigating if credentials aren't in the windows credential manager.

Tim
  • 616
  • 7
  • 23
0

guys iam changed my aws region then it works its cloned,add,commited and pushed in commitcode repository .And also add credentials in iam user and also attached some policys it works for me ,hear is my policys attached to user commitcode full access and json format

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "CodeCommitClonePullPermissions",
            "Effect": "Allow",
            "Action": [
                "codecommit:GitClone",
                "codecommit:GitPull"
            ],
            "Resource": "arn:aws:codecommit:AWSregion:AWSaccountid:my-reponame"
        }
    ]
}
Arpit Jain
  • 1,599
  • 9
  • 23