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:
- You must have configured AWS CLI on your system. We can check it through this command.
- 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.
2. Create Repository:
$ aws codecommit create-repository --repository-name <name>
You will get output as shown below.
3. Get Details about a Repository:
$ aws codecommit get-repository --repository-name demorepo
4. Cloning Repository:
Move to the AWS Codecommit and copy the link from here for cloning.
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
6. Get Details about a particular branch:
$ aws codecommit get-branch --repository-name demorepo --branch-name <branch-name>
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>
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>
You can verify it by listing the branches by using this command:
$ aws codecommit list-repositories
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>
You can check it here.
10. Delete a Branch:
$ aws codecommit delete-branch --repository-name demorepo --branch-name <branch-name>
11. Delete CodeCommit Repository:
$ aws codecommit delete-repository --repository-name demorepo
So, Now when you will list the repositories you will find an empty list.
$ aws codecommit list-repositories
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!