Migrating Remote Repository from GitHub to AWS CodeCommit

Zenesys Technosys
5 min readNov 19, 2021

--

In this blog post, We will work on migrating a repository from GitHub to AWS CodeCommit.

What is AWS CodeCommit?

● It is a secure, highly scalable, managed source control service that can host private Git repositories.

● It eliminates the dependency of managing the infrastructure to host the source control system

● It has the same functionality as Git.

Features of CodeCommit

● Store the code securely

● Fully managed service by AWS

● Work collaboratively on the code

● Store anything, anytime

● It can be easily integrated with other AWS and third-party services

● Easy to scale version control projects

● Easy to migrate files

Process of Migration

● Setup an AWS CodeCommit Repository

● Implement Git Credentials with HTTPS for AWS CodeCommit Authentication

● Copying Remote Git Repository to the Local system

● Uploading Local Git repository to AWS CodeCommit Repository

Prerequisites

The IAM user should have the AWS Code Commit permission in order to set up the Repository

Set up an AWS CodeCommit Repository

Go to AWS Code Commit Console and select the preferred AWS region.

Click Create repository

Enter the repository name with a short description of the repository.

Add tags to the repository if required.

To improve the code quality for the Java-backed applications, Enable Amazon CodeGuru.

If Enabled, It will automatically set up an IAM Role with the permission to manage the code commit repository for the amazon Code Guru

To list all the repositories, Click Repositories in the left pane.

Select the Repository name. We can either use an HTTPS connection and /or SSH connection to connect with the AWS CodeCommit Repository.

Using the copy link, The code commit repository can be copied to the local system.

Also Read: AWS vs Azure vs Google Cloud

HTTPS Git Credentials for AWS CodeCommit

We need to set up the Git Credentials for the IAM user to be able to authenticate with the code commit repository and manage them.

To do so, Go to the IAM Console.

In the navigation pane, click Users

Select the IAM user, and then click Security Credentials

Under HTTPS Git credentials for AWS CodeCommit, Choose Generate Credentials,

A username and password will be provided. You should make a note of it.

These Git credentials will be used to upload the code from the local Git repository to the AWS Code commit repository.

Uploading Git Repository to Local System

First, we need to copy the remote Git repository to the local system, which is the local git repository.

— mirror option will be used to create a bare copy of the remote git repository to the local system.

The remote repository will be copied to a directory named awscommit-repo in the local machine...

The bare repo is used for migration purposes.

git clone — mirror https://github.com/Rahultest005/test-demo.git awscommit-repo

Once the remote repo is cloned to the local repository, We can push it to the AWS code commit repository.

Pushing Local Git repository to AWS CodeCommit

Go to the folder where the remote Git repository was cloned.

cd awscommit-repo

Using the git push command with — all option to push the repository with all the git branches.

The authentication method used to upload/push the code from Local to a remote repository is an HTTPS connection

The following command will only push the branches of the repository.

git push https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/test-codecommit-repo — all

To push along with the tags of the repository, run the below command.

— all option is replaced with — tags

git push https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/test-codecommit-repo — tags

Remote Git repository immigrated to AWS code commit repository successfully.

Verifying AWS CodeCommit Repository

In the verification process, We will check whether the repository with all the tags and branches is successfully migrated.

Go to AWS CodeCommit console,

Click Repositories to list all the AWS code commit repositories.

Click the Repository name.

The details about the repository such as Branches, Tags, Copy URL, etc. can be found here-

Go to each tag and branch to verify the contents.

Once verified, You can make a clone of the AWS code commit repository and start to commit code changes.

You May Also Like: How to Set up a Static Website Using S3 Bucket & CloudFront Distribution

Conclusion

We have learned to set up a local git repository and HTTPS connection for the local git repository to be pushed to the AWS code commit repository.

The remote Git repository is successfully migrated with all the branches and tags.

--

--

Zenesys Technosys
Zenesys Technosys

Written by Zenesys Technosys

Zenesys is an 11-year-old IT Company based in the USA. Our key services: Mobile & Web Development, RPA, CMS, UI/UX & Cloud Services, etc. with the best solution

No responses yet