How to Setup Git on EC2 for AWS CodeCommit


Connect to the instance:

chmod 400 KEYPAIR.pem
ssh -i KEYPAIR.pem ec2-user@EC2PublicIP

Install Git:

sudo yum install -y git

Setup Git Credential Helper:

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

Now you can clone the CodeCommit repo which will look something like the following:

https://git-codecommit.us-east-1.amazonaws.com/v1/repos/My-Repo