Step 1: Initial configuration for CodeCommit
Sign in to the AWS Console and open the IAM console at https://console.aws.amazon.com/iam/
In the IAM console, in the navigation pane, choose Users, and then choose the IAM user you want to configure for CodeCommit access.
On the Permissions tab, choose Add Permissions.
In Grant permissions, choose Attach existing policies directly.
From the list of policies, select AWSCodeCommitPowerUser or another managed policy for CodeCommit access. For more information, see AWS managed policies for CodeCommit.
After you have selected the policy you want to attach, choose Next: Review to review the list of policies to attach to the IAM user. If the list is correct, choose Add permissions.
Step 2: Install Git
* You can install Git according to your OS
For Redhat/CentOs/ Rocky Linux
#yum install git
For Ubuntu
#apt-get install git
Step 3: Configure credentials on Linux, macOS, or
Unix
Set up the public and private keys for Git and CodeCommit
* From the terminal on your local machine, run the ssh-keygen command, and follow the directions to save the file to the .ssh directory for your profile.
#ssh-keygen -t rsa -b 4096
* Run the following command to display the value of the public key file
#cat ~/.ssh/id_rsa.pub
* Copy this value. It looks similar to the following:
ssh-rsa EXAMPLE-AfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcNMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDAS=EXAMPLE user-name@ip-192-0-2-137
* Sign in to the AWS Management Console and open the IAM console at
In the IAM console, in the navigation pane, choose Users, and from the list of users, choose your IAM user.
On the user details page, choose the Security Credentials tab, and then choose Upload SSH public key.
Paste the contents of your SSH public key into the field, and then choose Upload SSH public key.
Copy or save the information in SSH Key ID (for example,
APKAEIBAERJR2EXAMPLE
)
User
is the SSH key ID you copied earlier:# vim ~/.ssh/configHost git-codecommit.*.amazonaws.comUser APKAEIBAERJR2EXAMPLEIdentityFile ~/.ssh/id_rsa
#chmod 600 ~/.ssh/config
#ssh git-codecommit.us-east-2.amazonaws.com
ssh
command with the -v
parameter. For example:#ssh -v git-codecommit.us-east-2.amazonaws.com
git clone ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo my-demo-repo
$ cd my-demo-repo
$ touch first-file
$ git status
$ git add first-file
$ git status
$git config --global user.name "Your Name Here" $git config --global user.email "your.email@example.com"
$ git commit -m "my first commit to aws CodeCommit"
$ git log
$ git push origin master or git push origin main #as per your environment
$git branch new-branch-name
$git checkout new-branch-name
$git push origin new-branch-name
$git pull origin branch-name
$git log
$git revert <commit-hash>
$git checkout staging
$git merge staging
resolve the issues, and then:
$ git add <conflicted-file>
$ git merge --continue
to commit the changes manually:
$git commit -m "Merge staging into master"
$ git push origin master