AWS CodeCommit
User Guide (API Version 2015-04-13)

The procedures in this guide support the new console design. If you choose to use the older version of the console, you will find many of the concepts and basic procedures in this guide still apply. To access help in the new console, choose the information icon.

Getting Started with AWS CodeCommit Tutorial

If you're new to AWS CodeCommit, this tutorial helps you learn how to use its features. In this tutorial, you create a repository in AWS CodeCommit. After you commit some changes to the AWS CodeCommit repository, you browse the files and view the changes. You can also create a pull request for others to review and comment on changes to your code.

The AWS CodeCommit console includes helpful information in a collapsible panel that you can open from the information icon or any “Info” link on the page. ( ). You can close this panel at any time.


            Viewing additional guidance in the console

If you are not familiar with Git, you might want to complete the Git with AWS CodeCommit Tutorial in addition to this tutorial. After you finish this tutorial, you should have enough practice to start using AWS CodeCommit for your own projects and in team environments.

Important

Before you begin, you must complete the prerequisites and setup, including:

  • Assigning permissions to the IAM user.

  • Setting up credential management for HTTPS or SSH connections on the local machine you use for this tutorial.

  • Configuring the AWS CLI if you want to use the command line or terminal for all operations, including to create the repository.

Step 1: Create an AWS CodeCommit Repository

You can use the AWS CodeCommit console to create an AWS CodeCommit repository. If you already have a repository you want to use for this tutorial, you can skip this step.

Note

Depending on your usage, you might be charged for creating or accessing a repository. For more information, see Pricing on the AWS CodeCommit product information page.

To create the AWS CodeCommit repository (console)

  1. Open the AWS CodeCommit console at https://console.aws.amazon.com/codesuite/codecommit/home.

  2. In the region selector, choose the region where you want to create the repository. For more information, see Regions and Git Connection Endpoints.

  3. On the Repositories page, choose Create repository.

  4. On the Create repository page, in Repository name, enter a name (for example, MyDemoRepo).

    Note

    Repository names can be no longer than 100 characters. For more information, see Limits.

  5. (Optional) In Description, enter a description (for example, My demonstration repository.). This can help you and other users identify the purpose of the repository.

  6. Choose Create.


              Creating a repository from the console

Note

If you use a name other than MyDemoRepo for your repository, be sure to use it in the remaining steps of this tutorial.

When the repository opens, you see information about how to add files directly from the AWS CodeCommit console.

Step 2: Add Files to Your Repository

You can add files to your repository by:

  • Creating a file directly in the AWS CodeCommit console.

  • Uploading a file from your local computer using the AWS CodeCommit console.

  • Using a Git client to clone the repository to your local computer, and then adding, committing, and pushing files to the AWS CodeCommit repository.

The simplest way to get started is to add a file from the AWS CodeCommit console.

  1. In the navigation bar for the repository, choose Code.

  2. Choose Add file, and then choose to create or upload a file from your computer.

  3. Do the following:

    • If you want to add the file to a different branch, from the drop-down list of branches, choose the branch where you want to add the file. The default branch is selected automatically for you. In the example shown here, the default branch is named master.

    • In Author name, enter the name you want displayed to other repository users.

    • In Email address, enter an email address.

    • (Optional) In Commit message, enter a brief message. Although this is optional, we recommend you add a commit message to help your team members understand why you added this file. If you do not enter a commit message, a default message is used.

    • If you're uploading a file, choose the file you want to upload.

    • If you're creating a file, in File name, enter a name for the file, and then in the code editor, enter the code you want to add.

    
                        A view of uploading a file in the AWS CodeCommit console
  4. Choose Commit changes.

For more information, see Working with Files in AWS CodeCommit Repositories.

To use a Git client to clone the repository, install Git on your local computer, and then clone the AWS CodeCommit repository. Add some files to the local repo and push them to the AWS CodeCommit repository. For an in-depth introduction, try the Git with AWS CodeCommit Tutorial. If you are familiar with Git, but are not sure how to do this with an AWS CodeCommit repository, you can view examples and instructions in Create a Commit, Step 2: Create a Local Repo, or Connect to a Repository.

After you have added some files to the AWS CodeCommit repository, you can view them in the console.

Step 3: Browse the Contents of Your Repository

You can use the AWS CodeCommit console to review the files in a repository or to quickly read the contents of a file. This helps you determine which branch to check out or whether to create a local copy of a repository.

  1. From Repositories, choose MyDemoRepo.

  2. The contents of the repository are displayed in the default branch for your repository. To change the view to another branch, or to view the code at a specific tag, choose the view selector button, and then choose the branch or tag you want to view from the list. Here the view is set to the master branch.

    
                  Browse the contents of a repository
  3. To view the contents of a file in your repository, choose the file from the list. Choose the gear icon to change the color display option of the displayed code.

    
                  View the contents of a file

For more information, see Browse Files in a Repository.

You can also browse the commit history of a repository. This helps you identify changes made in a repository, including when and by whom those changes were made.

  1. In the navigation pane for a repository, choose Commits. A history of commits for the repository in the default branch is displayed, in reverse chronological order.

    
                      The commit history view in the console
  2. Review the commit history by branch or by tag, and get details about commits by author, date, and more.

  3. To view the differences between a commit and its parent, choose the abbreviated commit ID. You can choose how the changes are displayed, including showing or hiding white space changes, and whether to view changes inline (Unified view) or side by side (Split view).

    Note

    Your preferences for viewing code and other console settings are saved as browser cookies whenever you change them. For more information, see Working with User Preferences.

    
                        Changes shown in Unified view, with white space
                            changes visible
  4. To view all comments on a commit, choose the commit and then scroll through the changes to view them inline. You can also add your own comments and reply to the comments made by others.

    For more information, see Comment on a Commit.

  5. To view the differences between any two commits specifiers, including tags, branches, and commit IDs, in the navigation pane, choose Commits, and then choose Compare commits.

    
                        Comparing a commit to the tip of a branch in Split view

    For more information, see Browse the Commit History of a Repository and Compare Commits.

  6. In Commits, choose the Commit visualizer tab.

    
                      A graphical view of a repository in the console

    The commit graph is displayed, with the subject line for each commit shown next to its point in the graph. The subject line display is limited to 80 characters.

  7. To see more details about a commit, choose its abbreviated commit ID. To render the graph from a specific commit, choose that point in the graph. For more information, see View a Graph of the Commit History of a Repository .

If you set up notifications for your repository, repository users can receive emails about repository events (for example, for pull requests or when someone comments on code). For more information, see Configuring Notifications for Events in an AWS CodeCommit Repository.

Step 4: Create and Collaborate on a Pull Request

When you work with other repository users, you might want to collaborate on code and review changes. You can create a pull request so that other users can review and comment on your code changes in a branch before you merge those changes into another branch.

Important

Before you can create a pull request, you must create a branch that contains the code changes you want to review. For more information, see Create a Branch.

  1. In the navigation pane, choose Pull requests.

  2. In Pull request, choose Create pull request.

    Tip

    You can also create pull requests from Branches and Code.

    In Create pull request, in Source, choose the branch that contains the changes you want reviewed. In Destination, choose the branch where you want the reviewed code to be merged when the pull request is closed. Choose Compare.

  3. Review the merge details and changes to confirm that the pull request contains the changes and commits you want reviewed. If so, in Title, enter a title for this review. This is the title that appears in the list of pull requests for the repository. In Description, enter details about what this review is about and any other useful information for reviewers. Choose Create.

    
                            Creating a pull request
  4. Your pull request appears in the list of pull requests for the repository. You can filter the view to show only open requests, closed requests, requests that you created, and more.

    
                        Viewing pull requests in a repository
  5. If you configured notifications for your repository and chose to notify users of pull request events, users receive email about your new pull request. Users can view the changes and comment on specific lines of code, files, and the pull request itself. They can also reply to comments. If necessary, you can push changes to the pull request branch, which updates the pull request.

    
                        Viewing activity in a pull request
  6. When you are satisfied that all the code changes have been reviewed and agreed to, from the pull request, do one of the following:

    • If you want to use the fast-forward merge option to automatically merge the branches as part of closing the pull request, choose Merge.

    • If you want to close the pull request without using the automatic fast-forward merge option to merge branches, choose Close pull request.

    • If there are merge conflicts in the branches that cannot be automatically resolved, use your local Git client to merge the branches and then push the merge. This closes the pull request.

    Note

    You can always manually merge branches, including pull request branches, by using the git merge command in your local repo and pushing your changes. AWS CodeCommit closes the pull request when you push the merged code.

For more information, see Working with Pull Requests.

Step 5: Next Steps

Now that you have familiarized yourself with AWS CodeCommit and some of its features, consider doing the following:

Step 6: Clean Up

If you are done with exploring AWS CodeCommit and no longer need the repository, you should delete the AWS CodeCommit repository and other resources you used in this tutorial so you won't continue to be charged for the storage space.

Important

After you delete this repository, you can no longer clone it to any local repo or shared repo. You also can no longer pull data from it, push data to it, or perform any Git operations, from any local repo or shared repo. This action cannot be undone.

If you configured notifications for your repository, deleting the repository also deletes the Amazon CloudWatch Events rule created for the repository. It does not delete the Amazon SNS topic used as a target for that rule.

If you configured triggers for your repository, deleting the repository does not delete the Amazon SNS topics or Lambda functions you configured as the targets of those triggers. Be sure to delete those resources if you don't need them. For more information, see Delete Triggers from a Repository.

To delete the AWS CodeCommit repository

  1. Open the AWS CodeCommit console at https://console.aws.amazon.com/codesuite/codecommit/home.

  2. In Repositories, choose the repository you want to delete. If you followed the naming convention in this topic, it is named MyDemoRepo.

  3. In the navigation pane, choose Settings.

  4. On the Settings page, in Delete repository, choose Delete repository.

  5. Type delete, and then choose Delete. The repository is permanently deleted.