Fixing AWS CodeCommit git error on OS X

Fixing AWS CodeCommit git error on OS X

When using AWS CodeCommit (and I think specifically a MacBook / OS X) you might get the error:

fatal: repository 'https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/demo/' not found

Make sure you have a current version of git installed. CodeCommit supports Git versions 1.7.9 and later. Then try the following command:

git config --global credential.UseHttpPath true

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 $@'

After that, it works:

git clone https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/demo
Cloning into 'demo'...
remote: Counting objects: 2215, done.
Receiving objects: 100% (2215/2215), done.
Resolving deltas: 100% (1605/1605), done.

Hope it helps!