DEV Community

Nao San for AWS Community Builders

Posted on

[AWS] DevTools Evangelism: CodeCommit Edition

This article is a machine translation of the contents of the following URL, which I wrote in Japanese:

https://qiita.com/Nana_777/items/a8be2eee9ee9d81326cb

Introduction

This article is the first day of the Japan AWS Top Engineers Advent Calendar 2025.
I was selected as a Japan Top Engineer in 2025, but prior to that I was selected as a Community Builder in the DevTools field, so I plan to post more DevTools-related articles in the Advent Calendar.

AWS CodeCommit, whose phase-out was announced in July 2024, was canceled on November 24, 2025, and it became generally available again.
In this article, I'll explain what AWS CodeCommit is, a service that's once again attracting attention, along with how to use it.

↓Article about AWS CodeCommit's re-release

https://aws.amazon.com/jp/blogs/news/aws-codecommit-returns-to-general-availability/

↓Click here for the Japan AWS Top Engineers Advent Calendar 2025

https://qiita.com/advent-calendar/2025/aws-top-engineers

What is AWS CodeCommit?

AWS CodeCommit is a version control service provided by AWS that hosts repositories. Similar services include GitHub and GitLab.

AWS CodeCommit Initial Setup

Creating a Repository

In the CodeCommit console, select "Create Repository."
image.png
Enter the repository name and a description of its purpose.
image.png

Connecting to the Repository

Generate Credentials

Generate credentials for a user accessing CodeCommit in the IAM console.

image.png

GitClone from the VS Code console

Copy the repository URL.
image.png

Enter the following command in the VS Code console:

git clone [Copied URL]
Enter fullscreen mode Exit fullscreen mode

The authentication screen shown below will appear. Enter the authentication information you generated in the IAM console.
image.png

If the git clone command generates a folder with the repository name and a .git file inside it in a folder on your local PC, the command is successful.
(In this case, the repository is empty, so there will be no other files.)
image.png

:::note warn
When an error code 403 appears
If a user does not have the appropriate permissions to operate CodeCommit, an error with a 403 error code may occur.
In this case, configure a policy that allows the user to operate CodeCommit in the AWS console.
:::

Basic operations (add/commit/push)

Basic operations are the same as standard Git operations. You can use a GUI tool like SourceTree or execute Git commands from a terminal.

Managing local files in a CodeCommit repository (commit/push)

Create a file on your local PC

For testing purposes, I created a text file with some appropriate text.
The file contents are "CodeCommitTest."
image.png

Registering modified files in the staging area: git add

Select the files to be committed using git add file.
Execute the following command to register the file in the staging area.

git add [filename]
Enter fullscreen mode Exit fullscreen mode

image.png

Record the file in the staging area in the local repository: git commit

Execute the following command to record the file in the staging area in the local repository:

git add -m "【Commit message】"
Enter fullscreen mode Exit fullscreen mode

image.png

Registering changes to the remote repository: git push

Use the following git push command to register changes to the remote repository.

git push
Enter fullscreen mode Exit fullscreen mode

image.png

At this point, you can view the contents of the modified file in the AWS console.
image.png

Basic Operations (Branch Operations)

Creating a Working Branch git branch branch_name

When modifying files in a repository, rather than directly modifying the Master or Main branch, it's common to create a working branch, make edits in that branch, and then merge the inspected version into the Master branch.
You can create a working branch using the following command:

git branch [branch name]
Enter fullscreen mode Exit fullscreen mode

In this example, we created a branch named dev.
image.png

Checking the current branch: git branch

You can check the branch you're currently working on using the git branch command.
Please note that you will not be working on the branch immediately after creating it.
image.png

Switching to a working branch git checkout branch_name

To switch branches, execute checkout.
image.png

Once you've switched to your working branch (checked it out), you can update or create files and push them. You can then view the branch and changes in the CodeCommit console.
This time, we'll add a new file.
image.png

:::note warn
Error during initial push of new working branch
As shown in the screenshot above, an error occurred during the initial push using only git push.
git push --set-upstream origin [branch name]
The correct command for the initial push is:
:::
image.png

Creating and merging a pull request (using the CodeCommit console)

Creating a pull request

After the changes in the working branch are pushed, check them and merge them into the original branch (master in this case).
You can do this in the CodeCommit console, so here's how.
Select your repository and choose "Create a pull request."
image.png
Select the target (the branch from which the changes will be taken) and source (the branch from which the changes will be taken) and choose the "Compare" button.
image.png

A page will open where you can enter the title and description of your pull request. Here, write a message to let reviewers know about the changes.
image.png
You can review the changes to be merged at the bottom of the screen, making sure there are no unexpected changes.
If there are no problems, create the pull request.
image.png

Approving (Merging) a Pull Request

Reviewers can view a list of pending pull requests by clicking "Pull Requests" in the left menu of the CodeCommit console.
image.png
Select the name of the pull request to view the changes included in the pull request.
If there are no issues with the changes, click the Merge button to merge them. You can also add comments about your changes at the bottom of the screen (you must save them).
image.png
image.png
After clicking the Merge button, you'll be prompted to select a merge strategy.
Personally, I often use the 3-way merge.
image.png
Enter the merge commit message, author, and email address at the bottom of the screen. You can also optionally delete the merged branch (the branch into which the changes will be incorporated) after the merge.
image.png

As a result of the merge, the files added to the dev branch are visible in the master branch file list screen.
image.png

Repository Event Notification Settings

For CodeCommit-related features beyond basic Git operations, you can set notification rules.
For example, if you want to notify reviewers after submitting a pull request, manually contacting them separately from CodeCommit operations can be tedious.
You can reduce this hassle by configuring settings to automatically take necessary actions, such as notifications, in conjunction with pull requests and other actions in CodeCommit.

I've covered this topic in an earlier article, so please take a look.

I'll add more if I have time.

https://qiita.com/Nana_777/items/2808d25ca686b557d01a

Conclusion

AWS CodeCommit can be used on its own, but it can also be integrated with other services such as AWS CodeDeploy and AWS CodePipeline.
I'll cover this in a future article.

Reference

↓ Official AWS CodeCommit documentation

https://docs.aws.amazon.com/ja_jp/codecommit/latest/userguide/welcome.html

↓ AWS CodeCommit BlackBelt documentation (Japanese)

https://pages.awscloud.com/rs/112-TZM-766/images/20201020_BlackBelt_AWS_CodeCommit_AWS_CodeArtifact.pdf

Top comments (0)