Category Archives: Uncategorized

Migrating Gitlab or Github git repo to AWS CodeCommit

AWS CodeCommit is a git repo service. It is generally cheaper than other “pro” options provided by many comapnies. But this document is generally applicable to any git migration. You need to clone the source repo, add a new remote and push the changes.

Steps are given below

SSH Key

First , create a ssh key pair if you have not done so . If you do not have one , use the ssh-keygen command to generate a public and private key. ( For windows users, install git for windows client and then run the commands in the bash terminal that comes with it )

Upload your ssh public key to your user settings area in github or gitlab.

Clone the source Repo

git clone --mirror git@gitlab.com/blah/myproject.git

or

git clone --mirror git@github.com/myproject.git

or any other URL you might have.

This creates a myproject folder in your computer . This is what we are going to push to CodeCommit repo. Remember this is a bare repo just just like a snapshot that is going to AWS code commit repo. It will have all branches and commit history till now. So, make no changes any further in your original git repo.

Prepare AWS account

Account Settings

Login to AWS IAM area, find and click your username under “Users”. Go to “Security Credentials” tab. Find the button called “upload ssh key” and upload your ssh public key in there. After you add it, the screen shows the SSH Key as added and a ID associated with it. Copy the ID . It looks like AKWDCSFF123123SFDF .

Create a ~/.ssh/config file on your machine. Contents should look like below. Match your SSH ID and private key. Now your machine is ready to work with CodeCommit repo.

Host git-codecommit.*.amazonaws.com
    User APKAEBLAHEXAMPLE
    IdentityFile ~/.ssh/id_rsa

Create a CodeCommit Repo

Go to AWS CodeCommit and Click on Create Repository. Provide a name and click create.

Prepare and push the repo to CodeCommit

Get the repo URL from AWS CodeCommit as given in the below image.

Now run the following commands

cd myproject.git
git remote add aws ssh://git-codecommit.<yourregion>.amazonaws.com/v1/repos/<reponame>
git push --all aws

You should now be able to open the repo in CodeCommit UI in AWS, and see all your branches and commits are there.

Remove the myproject.git folder and do a fresh git clone from the CodeCommit . You can use this repo to do your future work.

If you used Wikis feature in gitlab, then you can use the “checkout” option on the wiki page which is yet another git repo. I recommend creating a seperate repo in AWS CodeCommit and do the same process above to save your Wiki pages as well.

An interesting Blunder !!

Ok. I admit that was a huge blunder then.. I got this information confirmed from various other websotes too.

eg : http://www.popechart.com/Popelist.htm

So.. I am not removing this article from my blog anyway… let it be there as an eternal warning for me to doublecheck the facts before doing such things.

Thank you very much Ranjit.

Or should I say.. “I was just chekcing to see if you guys are gonna fall for that..” :))

An interesting coincidence !

In 1981, the Pope died, Prince Charles got married and Liverpool were
crowned Champions of Europe.

This year (2005), the Pope died, Prince Charles got married and
Liverpool were crowned Champions of Europe.!

Next time, if Charles wants to re-marry or Liverpool needs another
crown, poor Pope …

🙂

Welcome!

Welcome to my blog.. This is the place where I share my thoughts, ideas, tech stuff and jokes.

I started blogging last month immediately after getting my domain name registered. As usual , I lost my enthusiasm in blogging after a couple of days. Thanks to Joseph for bringing me back to this.

Actually I tried to do it using my own code but soon realised that re-inventing the wheel is not an easy thing !

So I installed WordPress, a good blogger software which is totally free and does not eat up so much space in my web server. 🙂