Adding AWS Code Commit to an existing project

Adding AWS Code Commit to an existing project is very simple.
1. First we will need to use the git add remote command.
git remote add aws https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/your-project/
2. After adding the reference, we can now push the repository.
git push u aws main
3. When trying to push, it might ask you for a username and password. It could also return this error:
Username for 'https://git-codecommit.ap-northeast-1.amazonaws.com': yourusername
Password for 'https://yourusername@git-codecommit.ap-northeast-1.amazonaws.com': 
fatal: unable to access 'https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/your-project/': The requested URL returned error: 403
In order to solve this problem we only need to tweak the config with the following command:
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
After entering those commands, AWS will no longer ask for your credentials every time you push.
git push -u aws main
Counting objects: 445, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (320/320), done.
Writing objects: 100% (445/445), 104.48 KiB | 2.75 MiB/s, done.
Total 445 (delta 131), reused 0 (delta 0)
To https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/your-project/
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'aws'.

Comments