4

How to Manage AWS CodeCommit via AWS CLI

 2 years ago
source link: https://blog.knoldus.com/how-to-manage-aws-codecommit-via-aws-cli/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Reading Time: 4 minutes

Hello Readers! I hope you all are doing very well. So, In this blog we will see how to manage AWS CodeCommit via AWS CLI. Whatever you are doing with your AWS Management Console You can do it through AWS CLI. 

Now we are going to see how we can create a repository, create a branch and I have got a list of things that I’m going to show you now.

Prerequisites and SetUp:

  1. You must have configured AWS CLI on your system. We can check it through this command.

aws configure

  1. You must have git for performing all the functions and cloning the repo.

So, these are some prerequisites that you must follow before getting started.

Let’s start!

1.List the CodeCommit Repository:

   The command for listing CodeCommit Repository is:

$ aws codecommit list-repositories

You can see here there is no repository found.b3wTEkD-blUPPFU36NesunH6v2W-yghN6V6HJ7q13meHSaguD5x78dvuepfCm0huxH1t1w4bs0VK8lRTCGcSWgTAQcRk0TI-h6h4UlA6OvVu7Ukp91Hly16gy6bvMT40NSiN4ZB5

2. Create Repository:

$ aws codecommit create-repository --repository-name <name>

You will get output as shown below.

AWS Codecommit

AWS Codecommit

3. Get Details about a Repository:

$ aws codecommit get-repository --repository-name demorepo

Codecommit Repository

4. Cloning Repository:

Move to the AWS Codecommit and copy the link from here for cloning.

Repository

AWS Codecommit

I will move inside the repository and will create a file and push this file into the repository.

$ cd demorepo
$ touch myfile
$ git add .
$ git commit -m "added my first file"
$ git push

5. List Branches:

Use the following command for listing the branch of any repository.

$ aws codecommit list-branches --repository-name demorepo

AWS Codecommit

6. Get Details about a particular branch:

$ aws codecommit get-branch --repository-name demorepo --branch-name <branch-name>

AWS Codecommit

Here you will get a commit-id which you can use for further commands.

7. Get Details of the commit to our Repository:

$ aws codecommit get-commit --repository-name demorepo --commit-id <id>

codecommit

8. Create a Branch:

Use this command for creating the branch in our repository.

$ aws codecommit create-branch --repository-name demorepo --branch-name <branch-name> --commit-id <id>

branch

You can verify it by listing the branches by using this command:

$ aws codecommit list-repositories

codecommit

So, it’s created as you can see.

9. Update Default Branch

$ aws codecommit update-default-branch --repository-name demorepo --default-branch-name <branch-name>

default branch

You can check it here.

demorepo

10. Delete a Branch:

$ aws codecommit delete-branch --repository-name demorepo --branch-name <branch-name>

delete-branch

11. Delete CodeCommit Repository:

$ aws codecommit delete-repository --repository-name demorepo

repository

So, Now when you will list the repositories you will find an empty list.

$ aws codecommit list-repositories

repository-list

codecommit

Congrats! 👏 We are successfully done now! If you want then you can try more commands by using the help command.

Conclusion

In this blog we have seen how to manage AWS CodeCommit via AWS CLI. We have also seen some commands we can use. Thanks for being with me till the end. If you find this blog helpful do share with your friends.

HAPPY LEARNING!

Scala Future


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK