

# Working with commits in AWS CodeCommit repositories
<a name="commits"></a>

Commits are snapshots of the contents and changes to the contents of your repository. Every time a user commits and pushes a change, that information is saved and stored. So, too, is information that includes who committed the change, the date and time of the commit, and the changes made as part of the commit. You can also add tags to commits, to easily identify specific commits. In CodeCommit, you can:
+ Review commits.
+ View the history of commits in a graph.
+ Compare a commit to its parent or to another specifier.
+ Add comments to your commits and reply to comments made by others.

![\[Adding a comment to a changed line in a commit.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commenting-addlinecomment.png)


Before you can push commits to a CodeCommit repository, you must set up your local computer to connect to the repository. For the simplest method, see [For HTTPS users using Git credentials](setting-up-gc.md). 

For information about working with other aspects of your repository in CodeCommit, see [Working with repositories](repositories.md), [Working with files](files.md), [Working with pull requests](pull-requests.md) , [Working with branches](branches.md), and [Working with user preferences](user-preferences.md). 

**Topics**
+ [Create a commit in AWS CodeCommit](how-to-create-commit.md)
+ [View commit details in AWS CodeCommit](how-to-view-commit-details.md)
+ [Compare commits in AWS CodeCommit](how-to-compare-commits.md)
+ [Comment on a commit in AWS CodeCommit](how-to-commit-comment.md)
+ [Create a Git tag in AWS CodeCommit](how-to-create-tag.md)
+ [View Git tag details in AWS CodeCommit](how-to-view-tag-details.md)
+ [Delete a Git tag in AWS CodeCommit](how-to-delete-tag.md)

# Create a commit in AWS CodeCommit
<a name="how-to-create-commit"></a>

When you create the first commit for a new repository, you use the AWS CLI and the **put-file** command. This creates the first commit and it allows you to create and specify the default branch for your new repository. You can use Git or the AWS CLI to create a commit in a CodeCommit repository. If the local repo is connected to a CodeCommit repository, you use Git to push the commit from the local repo to the CodeCommit repository. To create a commit directly in the CodeCommit console, see [Create or add a file to an AWS CodeCommit repository](how-to-create-file.md) and [Edit the contents of a file in an AWS CodeCommit repository](how-to-edit-file.md). 

**Note**  
As a best practice, we recommend that you use the latest supported versions of the AWS CLI, Git, and other software. If you use the AWS CLI, make sure that you have a recent version installed to ensure that you are using a version that contains the `create-commit` command.

**Topics**
+ [Create the first commit for a repository using the AWS CLI](#how-to-create-first-commit)
+ [Create a commit using a Git client](#how-to-create-commit-git)
+ [Create a commit using the AWS CLI](#how-to-create-commit-cli)

## Create the first commit for a repository using the AWS CLI
<a name="how-to-create-first-commit"></a>

You can use the AWS CLI and the `put-file` command to create your first commit for a repository. Using **put-file** creates a first commit that adds a file to your empty repository, and it creates a branch with the name you specify. It designates the new branch as the default branch for your repository. 

**Note**  
To use AWS CLI commands with CodeCommit, install the AWS CLI. For more information, see [Command line reference](cmd-ref.md). <a name="create-first-commit"></a>

## To create the first commit for a repository using the AWS CLI


1. On your local computer, create the file you want to add as the first file to the CodeCommit repository. A common practice is to create a `README.md` markdown file that explains the purpose of this repository to other repository users. If you include a `README.md` file, the content of the file is displayed automatically at the bottom of the **Code** page for your repository in the CodeCommit console.

1. At the terminal or command line, run the **put-file** command, specifying:
   + The name of the repository where you want to add the first file.
   + The name of the branch you want to create as the default branch.
   + The local location of the file. The syntax used for this location varies, depending on your local operating system.
   + The name of the file you want to add, including the path where the updated file is stored in the repository.
   + The user name and email you want to associate with this file.
   + A commit message that explains why you added this file.

   The user name, email address, and commit message are optional, but can help other users know who made the change and why. If you do not supply a user name, CodeCommit defaults to using your IAM user name or a derivation of your console login as the author name.

   For example, to add a file named *README.md* with  example base 6 encoded file content  to a repository named *MyDemoRepo* to a branch named *development*:

   ```
   aws codecommit put-file --repository-name MyDemoRepo --branch-name development --file-path README.md --file-content "EXAMPLE0123456789example0123456789EXAMPLE1" --name "Mary Major" --email "mary_major@example.com" --commit-message "I added a quick readme for our new team repository."
   ```

   If successful, this command returns output similar to the following:

   ```
   {
       "commitId": "724caa36EXAMPLE",
       "blobId": "a8a94062EXAMPLE",
       "treeId": "08b2fc73EXAMPLE"
   }
   ```

## Create a commit using a Git client
<a name="how-to-create-commit-git"></a>

You can create commits using a Git client installed on your local computer, and then push those commits to your CodeCommit repository.

1. Complete the prerequisites, including [Setting up ](setting-up.md).
**Important**  
If you have not completed setup, you cannot connect or commit to the repository using Git.

1. Make sure you are creating a commit in the correct branch. To see a list of available branches and find out which branch you are currently set to use, run **git branch**. All branches are displayed. An asterisk (`*`) appears next to your current branch. To switch to a different branch, run **git checkout *branch-name***. If this is your first commit, run the **git config ** command to configure your Git client to create an initial branch with the name you want to use for that branch. For example, if you want your default branch to have the name *development*:

   ```
   git config --local init.defaultBranch development
   ```
**Tip**  
This command is only available in Git v.2.28 and later.  
You can also run this command to set your default branch name to **development** for all newly-created repositories:  

   ```
   git config --global init.defaultBranch development
   ```

1. Make a change to the branch (such as adding, modifying, or deleting a file).

   For example, in the local repo, create a file named `bird.txt` with the following text:

   ```
   bird.txt
   --------
   Birds (class Aves or clade Avialae) are feathered, winged, two-legged, warm-blooded, egg-laying vertebrates.
   ```

1. Run **git status**, which should indicate that `bird.txt` has not yet been included in any pending commit:

   ```
   ...        
   Untracked files:
     (use "git add <file>..." to include in what will be committed)
           
           bird.txt
   ```

1. Run **git add bird.txt** to include the new file in the pending commit.

1. If you run **git status** again, you should see output similar to the following. It indicates that `bird.txt` is now part of the pending commit or staged for commit:

   ```
   ...
   Changes to be committed:
     (use "git reset HEAD <file>..." to unstage)
       
           new file:   bird.txt
   ```

1. To finalize the commit, run **git commit** with the `-m` option (for example, ** git commit -m "*Adding bird.txt to the repository.*"**) The `-m` option creates the commit message. 

1. If you run **git status** again, you should see output similar to the following. It indicates that the commit is ready to be pushed from the local repo to the CodeCommit repository:

   ```
   ...    
   nothing to commit, working directory clean
   ```

1. Before you push the finalized commit from the local repo to the CodeCommit repository, you can see what you are pushing by running **git diff --stat *remote-name*/*branch-name***, where *remote-name* is the nickname the local repo uses for the CodeCommit repository and *branch-name* is the name of the branch to compare.
**Tip**  
To get the nickname, run **git remote**. To get a list of branch names, run **git branch**. An asterisk (`*`) appears next to the current branch. You can also run **git status** to get the current branch name.
**Note**  
If you cloned the repository, from the perspective of the local repo, *remote-name* is not the name of the CodeCommit repository. When you clone a repository, *remote-name* is set automatically to `origin`. 

   For example, **git diff --stat origin/main** would show output similar to the following:

   ```
   bird.txt | 1 +
   1 file changed, 1 insertion(+)
   ```

   The output assumes you have already connected the local repo to the CodeCommit repository. (For instructions, see [Connect to a repository](how-to-connect.md).)

1. When you're ready to push the commit from the local repo to the CodeCommit repository, run **git push *remote-name* *branch-name***, where *remote-name* is the nickname the local repo uses for the CodeCommit repository and *branch-name* is the name of the branch to push to the CodeCommit repository.

   For example, running **git push origin main** would show output similar to the following:

   For HTTPS:

   ```
   Counting objects: 7, done.
   Delta compression using up to 4 threads.
   Compressing objects: 100% (4/4), done.
   Writing objects: 100% (5/5), 516 bytes | 0 bytes/s, done.
   Total 5 (delta 2), reused 0 (delta 0)
   remote:
   To https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo
       b9e7aa6..3dbf4dd main -> main
   ```

   For SSH:

   ```
   Counting objects: 7, done.
   Delta compression using up to 4 threads.
   Compressing objects: 100% (4/4), done.
   Writing objects: 100% (5/5), 516 bytes | 0 bytes/s, done.
   Total 5 (delta 2), reused 0 (delta 0)
   remote:
   To ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo
       b9e7aa6..3dbf4dd main -> main
   ```
**Tip**  
If you add the `-u` option to **git push** (for example, **git push -u origin main**), then you only need to run **git push** in the future because upstream tracking information has been set. To get upstream tracking information, run **git remote show *remote-name*** (for example, **git remote show origin**).

For more options, see your Git documentation.

## Create a commit using the AWS CLI
<a name="how-to-create-commit-cli"></a>

You can use the AWS CLI and the `create-commit` command to create a commit for a repository on the tip of a specified branch. You can also create an unreferenced merge commit to represent the results of merging two commit specifiers. For more information, see [Create an unreferenced commit](how-to-resolve-conflict-pull-request.md#create-unreferenced-merge-commit).

**Note**  
To use AWS CLI commands with CodeCommit, install the AWS CLI. For more information, see [Command line reference](cmd-ref.md). <a name="create-commit"></a>

**To create a commit**

1. On your local computer, make the changes you want committed to the CodeCommit repository.

1. At the terminal or command line, run the **create-commit** command, specifying:
   + The repository where you want to commit the changes.
   + The branch where you want to commit the changes.
   + The full commit ID of the most recent commit made to that branch, also known as the tip or head commit or the parent commit ID.
   + Whether to keep any empty folders if the changes you made delete the content of those folders. By default, this value is false.
   + The information about the files you want added, changed, or deleted.
   + The user name and email you want associated with these changes.
   + A commit message that explains why you made these changes.

   The user name, email address, and commit message are optional, but help other users know who made the changes and why. If you do not supply a user name, CodeCommit defaults to using your IAM user name or a derivation of your console login as the author name.

   For example, to create a commit for a repository that adds a `README.md` file to a repository named *MyDemoRepo* in the *main* branch. The content of the file is in Base64 and reads "Welcome to our team repository\$1":

   ```
   aws codecommit create-commit --repository-name MyDemoRepo --branch-name main --parent-commit-id 4c925148EXAMPLE --put-files "filePath=README.md,fileContent=V2VsY29tZSB0byBvdXIgdGVhbSByZXBvc2l0b3J5IQo="
   ```
**Tip**  
To get the parent commit ID, run the [get-branch](how-to-view-branch-details.md#how-to-view-branch-details-cli-details) command.

   If successful, this command returns output similar to the following:

   ```
   {
       "commitId": "4df8b524-EXAMPLE",
       "treeId": "55b57003-EXAMPLE",
       "filesAdded": [
           {
               "blobId": "5e1c309dEXAMPLE",
               "absolutePath": "meeting.md",
               "fileMode": "NORMAL"
           }
       ],
       "filesDeleted": [],
       "filesUpdated": []
   }
   ```

   To create a commit that makes changes to files named *file1.py* and *file2.txt*, renames a file from *picture.png* to *image1.png* and moves it from a directory named *pictures* to a directory named, *images*, and deletes a file named *ExampleSolution.py* in a repository named *MyDemoRepo* on a branch named *MyFeatureBranch* whose most recent commit has an ID of *4c925148EXAMPLE*:

   ```
   aws codecommit create-commit --repository-name MyDemoRepo --branch-name MyFeatureBranch --parent-commit-id 4c925148EXAMPLE --author-name "Saanvi Sarkar"
    --email "saanvi_sarkar@example.com" --commit-message "I'm creating this commit to update a variable name in a number of files."
    --keep-empty-folders false  --put-files '{"filePath": "file1.py", "fileMode": "EXECUTABLE", "fileContent": "bucket_name = sys.argv[1] region = sys.argv[2]"}'
   '{"filePath": "file2.txt", "fileMode": "NORMAL", "fileContent": "//Adding a comment to explain the variable changes in file1.py"}' '{"filePath": "images/image1.png",
   "fileMode": "NORMAL", "sourceFile": {"filePath": "pictures/picture.png", "isMove": true}}' --delete-files filePath="ExampleSolution.py"
   ```
**Note**  
The syntax for the **--put-files** segment varies depending on your operating system. The above example is optimized for Linux, macOS, or Unix users and Windows users with a Bash emulator. Windows users at the command line or in Powershell should use syntax appropriate for those systems.

   If successful, this command returns output similar to the following:

   ```
   {
      "commitId": "317f8570EXAMPLE",
      "treeId": "347a3408EXAMPLE",
      "filesAdded": [
           {
           "absolutePath": "images/image1.png",
           "blobId": "d68ba6ccEXAMPLE",
           "fileMode": "NORMAL"
           }
       ],
       "filesUpdated": [
           {
           "absolutePath": "file1.py",
           "blobId": "0a4d55a8EXAMPLE",
           "fileMode": "EXECUTABLE"
           },
           {
           "absolutePath": "file2.txt",
           "blobId": "915766bbEXAMPLE",
           "fileMode": "NORMAL"
           }
       ],
       "filesDeleted": [
           {
           "absolutePath": "ExampleSolution.py",
           "blobId": "4f9cebe6aEXAMPLE",
           "fileMode": "EXECUTABLE"
           },
           {
           "absolutePath": "pictures/picture.png",
           "blobId": "fb12a539EXAMPLE",
           "fileMode": "NORMAL"
           }
       ]
   }
   ```

# View commit details in AWS CodeCommit
<a name="how-to-view-commit-details"></a>

You can use the AWS CodeCommit console to browse the history of commits in a repository. This can help you identify changes made in a repository, including:
+ When and by whom the changes were made.
+ When specific commits were merged into a branch.

Viewing the history of commits for a branch might also help you understand the difference between branches. If you use tagging, you can also quickly view the commit that was labeled with a tag and the parents of that tagged commit. At the command line, you can use Git to view details about the commits in a local repo or a CodeCommit repository. 

## Browse commits in a repository
<a name="how-to-view-commit-details-console"></a>

You can use the AWS CodeCommit console to browse the history of commits to a repository. You can also view a graph of the commits in the repository and its branches over time. This can help you understand the history of the repository, including when changes were made.

**Note**  
Using the **git rebase** command to rebase a repository changes the history of a repository, which might cause commits to appear out of order. For more information, see [Git Branching-Rebasing](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) or your Git documentation.

**Topics**
+ [Browse the commit history of a repository](#how-to-view-commit-details-console-history)
+ [View a graph of the commit history of a repository](#how-to-view-commit-details-console-visualizer)

### Browse the commit history of a repository
<a name="how-to-view-commit-details-console-history"></a>

You can browse the commit history for a specific branch or tag of the repository, including information about the committer and the commit message. You can also view the code for a commit.

**To browse the history of commits**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the repository for which you want to review the commit history. 

1. In the navigation pane, choose **Commits**. In the commit history view, a history of commits for the repository in the default branch is displayed, in reverse chronological order of the commit date. Date and time are in coordinated universal time (UTC). You can view the commit history of a different branch by choosing the view selector button and then choosing a branch from the list. If you are using tags in your repository, you can view a commit with a specific tag and its parents by choosing that tag in the view selector button.  
![\[The commits view in the console\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commit-list.png)

1. To view the difference between a commit and its parent, and to see any comments on the changes, choose the abbreviated commit ID. For more information, see [Compare a commit to its parent](how-to-compare-commits.md#how-to-compare-commits-parent) and [Comment on a commit](how-to-commit-comment.md). To view the difference between a commit and any other commit specifier, including a branch, tag, or commit ID, see [Compare any two commit specifiers](how-to-compare-commits.md#how-to-compare-commits-compare).

1. Do one or more of the following:
   + To view the date and time a change was made, hover over the commit date.
   + To view the full commit ID, copy and then paste it into a text editor or other location. To copy it, choose **Copy ID**.
   + To view the code as it was at the time of a commit, choose **Browse**. The contents of the repository as they were at the time of that commit is displayed in the **Code** view. The view selector button displays the abbreviated commit ID instead of a branch or tag.

### View a graph of the commit history of a repository
<a name="how-to-view-commit-details-console-visualizer"></a>

You can view a graph of the commits made to a repository. The **Commit Visualizer** view is a directed acyclic graph (DAG) representation of all the commits made to a branch of the repository. This graphical representation can help you understand when commits and associated features were added or merged. It can also help you pinpoint when a change was made in relation to other changes.

**Note**  
Commits that are merged using the fast-forward method do not appear as separate lines in the graph of commits.

**To view a graph of commits**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the repository for which you want to view a commit graph. 

1. In the navigation pane, choose **Commits**, and then choose the **Commit visualizer** tab.  
![\[A graphical view of a repository in the console\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-cv-complex1.png)

   In the commit graph, the abbreviated commit ID and the subject for each commit message appears next to that point in the graph. 
**Note**  
The graph can display up to 35 branches on a page. If there are more than 35 branches, the graph is too complex to display. You can simplify the view in two ways:   
By using the view selector button to show the graph for a specific branch.
By pasting a full commit ID into the search box to render the graph from that commit.

1. To render a new graph from a commit, choose the point in the graph that corresponds to that commit. The view selector button changes to the abbreviated commit ID.  
![\[A new graph rendered from a specific commit\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-cv-commit.png)

## View commit details (AWS CLI)
<a name="how-to-view-commit-details-cli"></a>

Git lets you view details about commits. You can also use the AWS CLI to view details about the commits in a local repo or in a CodeCommit repository by running the following commands:
+ To view information about a commit, run **[aws codecommit get-commit](#how-to-view-commit-details-cli-commit)**.
+ To view information about multiple commits, run **[aws codecommit batch-get-commits](#how-to-view-commit-details-cli-batch-get-commits)**.
+ To view information about a merge commit, run **[aws codecommit get-merge-commit](#how-to-view-commit-details-cli-merge-commit)**.
+ To view information about changes for a commit specifier (branch, tag, HEAD, or other fully qualified references, such as commit IDs), run **[aws codecommit get-differences](#how-to-view-commit-details-cli-differences)**.
+ To view the base64-encoded content of a Git blob object in a repository, run **[aws codecommit get-blob](#how-to-view-commit-details-cli-blob)**.

### To view information about a commit
<a name="how-to-view-commit-details-cli-commit"></a>

1. Run the **aws codecommit get-commit** command, specifying:
   + The name of the CodeCommit repository (with the `--repository-name` option).
   + The full commit ID. 

   For example, to view information about a commit with the ID `317f8570EXAMPLE` in a CodeCommit repository named `MyDemoRepo`:

   ```
   aws codecommit get-commit  --repository-name MyDemoRepo  --commit-id 317f8570EXAMPLE 
   ```

1. If successful, the output of this command includes the following:
   + Information about the author of the commit (as configured in Git), including the date in timestamp format and the coordinated universal time (UTC) offset.
   + Information about the committer (as configured in Git) including the date in timestamp format and the UTC offset.
   + The ID of the Git tree where the commit exists.
   + The commit ID of the parent commit.
   + The commit message.

   Here is some example output, based on the preceding example command:

   ```
   {
       "commit": {
           "additionalData": "",
           "committer": {
               "date": "1484167798 -0800",
               "name": "Mary Major",
               "email": "mary_major@example.com"
           },
           "author": {
               "date": "1484167798 -0800",
               "name": "Mary Major",
               "email": "mary_major@example.com"
           },
           "treeId": "347a3408EXAMPLE",
           "parents": [
               "4c925148EXAMPLE"
           ],
           "message": "Fix incorrect variable name"
       }
   }
   ```

### To view information about a merge commit
<a name="how-to-view-commit-details-cli-merge-commit"></a>

1. Run the **get-merge-commit** command, specifying:
   + A commit specifier for the source of the merge (with the **--source-commit-specifier** option).
   + A commit specifier for the destination for the merge (with the **--destination-commit-specifier** option). 
   + The merge option you want to use (with the **--merge-option** option).
   + The name of the repository (with the **--repository-name** option).

   For example, to view information about a merge commit for the source branch named *bugfix-bug1234* with a destination branch named *main* using the *THREE\$1WAY\$1MERGE* strategy in a repository named *MyDemoRepo*:

   ```
   aws codecommit get-merge-commit --source-commit-specifier bugfix-bug1234 --destination-commit-specifier main --merge-option THREE_WAY_MERGE --repository-name MyDemoRepo
   ```

1. If successful, the output of this command returns information similar to the following:

   ```
   {
       "sourceCommitId": "c5709475EXAMPLE", 
       "destinationCommitId": "317f8570EXAMPLE", 
       "baseCommitId": "fb12a539EXAMPLE",
       "mergeCommitId": "ffc4d608eEXAMPLE"
   }
   ```

### To view information about multiple commits
<a name="how-to-view-commit-details-cli-batch-get-commits"></a>

1. Run the **batch-get-commits** command, specifying:
   + The name of the CodeCommit repository (with the `--repository-name` option).
   + A list of full commit IDs for every commit about which you want to view information. 

   For example, to view information about commits with the IDs `317f8570EXAMPLE` and `4c925148EXAMPLE` in a CodeCommit repository named `MyDemoRepo`:

   ```
   aws codecommit batch-get-commits  --repository-name MyDemoRepo  --commit-ids 317f8570EXAMPLE 4c925148EXAMPLE
   ```

1. If successful, the output of this command includes the following:
   + Information about the authors of the commits (as configured in Git), including the date in timestamp format and the coordinated universal time (UTC) offset.
   + Information about the committers (as configured in Git) including the date in timestamp format and the UTC offset.
   + The IDs of the Git tree where the commit exists.
   + The commit IDs of the parent commit.
   + The commit messages.

   Here is some example output, based on the preceding example command:

   ```
   {
       "commits": [
         {
           "additionalData": "",
           "committer": {
               "date": "1508280564 -0800",
               "name": "Mary Major",
               "email": "mary_major@example.com"
           },
           "author": {
               "date": "1508280564 -0800",
               "name": "Mary Major",
               "email": "mary_major@example.com"
           },
           "commitId": "317f8570EXAMPLE",
           "treeId": "1f330709EXAMPLE",
           "parents": [
               "6e147360EXAMPLE"
           ],
           "message": "Change variable name and add new response element"
       },
       {
           "additionalData": "",
           "committer": {
               "date": "1508280542 -0800",
               "name": "Li Juan",
               "email": "li_juan@example.com"
           },
           "author": {
               "date": "1508280542 -0800",
               "name": "Li Juan",
               "email": "li_juan@example.com"
           },
           "commitId": "4c925148EXAMPLE",
           "treeId": "1f330709EXAMPLE",
           "parents": [
               "317f8570EXAMPLE"
           ],
           "message": "Added new class"
       }   
   }
   ```

### To view information about the changes for a commit specifier
<a name="how-to-view-commit-details-cli-differences"></a>

1. Run the **aws codecommit get-differences** command, specifying:
   + The name of the CodeCommit repository (with the `--repository-name` option).
   + The commit specifiers you want to get information about. Only `--after-commit-specifier` is required. If you do not specify `--before-commit-specifier`, all files current as of the `--after-commit-specifier` are shown. 

   For example, to view information about the differences between commits with the IDs `317f8570EXAMPLE` and `4c925148EXAMPLE` in a CodeCommit repository named `MyDemoRepo`:

   ```
   aws codecommit get-differences  --repository-name MyDemoRepo  --before-commit-specifier 317f8570EXAMPLE --after-commit-specifier 4c925148EXAMPLE
   ```

1. If successful, the output of this command includes the following:
   + A list of differences, including the change type (A for added, D for deleted, or M for modified).
   + The mode of the file change type.
   + The ID of the Git blob object that contains the change.

   Here is some example output, based on the preceding example command:

   ```
   {
       "differences": [
           {
               "afterBlob": {
                   "path": "blob.txt",
                   "blobId": "2eb4af3bEXAMPLE",
                   "mode": "100644"
               },
               "changeType": "M",
               "beforeBlob": {
                   "path": "blob.txt",
                   "blobId": "bf7fcf28fEXAMPLE",
                   "mode": "100644"
               }
           }
       ]
   }
   ```

### To view information about a Git blob object
<a name="how-to-view-commit-details-cli-blob"></a>

1. Run the **aws codecommit get-blob** command, specifying:
   + The name of the CodeCommit repository (with the `--repository-name` option).
   + The ID of the Git blob (with the `--blob-id `option). 

   For example, to view information about a Git blob with the ID of `2eb4af3bEXAMPLE` in a CodeCommit repository named `MyDemoRepo`:

   ```
   aws codecommit get-blob  --repository-name MyDemoRepo  --blob-id 2eb4af3bEXAMPLE
   ```

1. If successful, the output of this command includes the following:
   + The base64-encoded content of the blob, usually a file.

   For example, the output of the previous command might be similar to the following:

   ```
   {
       "content": "QSBCaW5hcnkgTGFyToEXAMPLE="
   }
   ```

## View commit details (Git)
<a name="how-to-view-commit-details-git"></a>

Before you follow these steps, you should have already connected the local repo to the CodeCommit repository and committed changes. For instructions, see [Connect to a repository](how-to-connect.md).

To show the changes for the most recent commit to a repository, run the **git show** command.

```
git show
```

The command produces output similar to the following:

```
commit 4f8c6f9d
Author: Mary Major <mary.major@example.com>
Date:   Mon May 23 15:56:48 2016 -0700

    Added bumblebee.txt

diff --git a/bumblebee.txt b/bumblebee.txt
new file mode 100644
index 0000000..443b974
--- /dev/null
+++ b/bumblebee.txt
@@ -0,0 +1 @@
+A bumblebee, also written bumble bee, is a member of the bee genus Bombus, in the family Apidae.
\ No newline at end of file
```

**Note**  
In this and the following examples, commit IDs have been abbreviated. The full commit IDs are not shown.

To view the changes that occurred, use the **git show** command with the commit ID:

```
git show 94ba1e60

commit 94ba1e60
Author: John Doe <johndoe@example.com>
Date:   Mon May 23 15:39:14 2016 -0700

    Added horse.txt

diff --git a/horse.txt b/horse.txt
new file mode 100644
index 0000000..080f68f
--- /dev/null
+++ b/horse.txt
@@ -0,0 +1 @@
+The horse (Equus ferus caballus) is one of two extant subspecies of Equus ferus.
```

To see the differences between two commits, run the **git diff** command and include the two commit IDs.

```
git diff ce22850d 4f8c6f9d
```

In this example, the difference between the two commits is that two files were added. The command produces output similar to the following:

```
diff --git a/bees.txt b/bees.txt
new file mode 100644
index 0000000..cf57550
--- /dev/null
+++ b/bees.txt
@@ -0,0 +1 @@
+Bees are flying insects closely related to wasps and ants, and are known for their role in pollination and for producing honey and beeswax.
diff --git a/bumblebee.txt b/bumblebee.txt
new file mode 100644
index 0000000..443b974
--- /dev/null
+++ b/bumblebee.txt
@@ -0,0 +1 @@
+A bumblebee, also written bumble bee, is a member of the bee genus Bombus, in the family Apidae.
\ No newline at end of file
```

To use Git to view details about the commits in a local repo, run the **git log** command:

```
git log
```

If successful, this command produces output similar to the following:

```
commit 94ba1e60
Author: John Doe <johndoe@example.com>
Date:   Mon May 23 15:39:14 2016 -0700

    Added horse.txt

commit 4c925148
Author: Jane Doe <janedoe@example.com>
Date:   Mon May 22 14:54:55 2014 -0700

    Added cat.txt and dog.txt
```

To show only commit IDs and messages, run the **git log --pretty=oneline** command:

```
git log --pretty=oneline
```

If successful, this command produces output similar to the following:

```
94ba1e60 Added horse.txt
4c925148 Added cat.txt and dog.txt
```

For more options, see your Git documentation.

# Compare commits in AWS CodeCommit
<a name="how-to-compare-commits"></a>

You can use the CodeCommit console to view the differences between commit specifiers in a CodeCommit repository. You can quickly view the difference between a commit and its parent. You can also compare any two references, including commit IDs. 

**Topics**
+ [Compare a commit to its parent](#how-to-compare-commits-parent)
+ [Compare any two commit specifiers](#how-to-compare-commits-compare)

## Compare a commit to its parent
<a name="how-to-compare-commits-parent"></a>

You can quickly view the difference between a commit and its parent to review the commit message, the committer, and what changed.

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. On the **Repositories** page, choose the repository where you want to view the difference between a commit and its parent. 

1. In the navigation pane, choose **Commits**.

1. Choose the abbreviated commit ID of any commit in the list. The view changes to show details for this commit, including the differences between it and its parent commit.  
![\[Choose the abbreviated commit ID to show differences between this commit and its parent\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commit-changes1.png)

   You can show changes side by side (**Split** view) or inline (**Unified** view). You can also hide or show white space changes. You can also add comments. For more information, see [Comment on a commit](how-to-commit-comment.md).
**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](user-preferences.md).  
![\[Changes shown in Unified view, with white space changes hidden\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commit-changes2c.png)  
![\[Changes shown in Split view, with a comment on a line\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commenting-commenttab.png)
**Note**  
 Depending on line ending style, your code editor, and other factors, you might see entire lines added or deleted instead of specific changes in a line. The level of detail matches what's returned in the **git show** or **git diff** commands.

1. To compare a commit to its parent, from the **Commit visualizer** tab, choose the abbreviated commit ID. The commit details, including the changes between the commit and its parent, are displayed.

## Compare any two commit specifiers
<a name="how-to-compare-commits-compare"></a>

You can view the differences between any two commit specifiers in the CodeCommit console. Commit specifiers are references, such as branches, tags, and commit IDs. 

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. On the **Repositories** page, choose the repository where you want to compare commits, branches, or tagged commits. 

1. In the navigation pane, choose **Commits**, and then choose **Compare commits**.  
![\[Compare any two commit specifiers\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-compare-1.png)

1. Use the boxes to compare two commit specifiers. 
   + To compare the tip of a branch, choose the branch name from the list. This selects the most recent commit from that branch for the comparison.
   + To compare a commit with a specific tag associated with it, choose the tag name from the list, if any. This selects the tagged commit for the comparison.
   + To compare a specific commit, enter or paste the commit ID in the box. To get the full commit ID, choose **Commits** in the navigation bar, and copy the commit ID from the list. On the **Compare commits** page, paste the full commit ID in the text box, and choose **Use commit ID**.   
![\[Compare branches, tags, or commit IDs\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-compare-2.png)

1. After you have selected the specifiers, choose **Compare**.   
![\[The comparison view between two branches\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-compare-branches.png)

   You can show differences side by side (**Split** view) or inline (**Unified** view). You can also hide or show white space changes.

1. To clear your comparison choices, choose **Cancel**.

# Comment on a commit in AWS CodeCommit
<a name="how-to-commit-comment"></a>

You can use the CodeCommit console to comment on commits in a repository, and view and reply to other users' comments on commits. This can help you discuss changes made in a repository, including:
+ Why changes were made.
+ Whether more changes are required.
+ Whether changes should be merged into another branch.

You can comment on an overall commit, a file in a commit, or a specific line or change in a file. You can also link to a line of code by selecting the line and then copying the resulting URL in your browser.

**Note**  
For best results, use commenting when you are signed in as an IAM user. The commenting functionality is not optimized for users who sign in with root account credentials, federated access, or temporary credentials.

**Topics**
+ [View comments on a commit in a repository](#how-to-commit-comment-view-console)
+ [Add and reply to comments on a commit in a repository](#how-to-commit-comment-add-console)
+ [View, add, update, and reply to commments (AWS CLI)](#how-to-commit-comment-cli)

## View comments on a commit in a repository
<a name="how-to-commit-comment-view-console"></a>

You can use the CodeCommit console to view comments on a commit. 

**To view comments on a commit**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the repository for which you want to review comments on commits. 

1. In the navigation pane, choose **Commits**. Choose the commit ID of the commit where you want to view any comments.

   The page for that commit is displayed, along with any comments.

## Add and reply to comments on a commit in a repository
<a name="how-to-commit-comment-add-console"></a>

You can use the CodeCommit console to add comments to the comparison of a commit and a parent, or to the comparison between two specified commits. You can also reply to comments with emojis, with your own comments, or both. 

### Add and reply to comments on a commit (console)
<a name="how-to-commit-comment-add-cpage"></a>

You can add and reply to comments to a commit with text and with emojis. Your comments and emojis are marked as belonging to the IAM user or role you used to sign in to the console.

**To add and reply to comments on a commit**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the repository where you want to comment on commits. 

1. In the navigation pane, choose **Commits**. Choose the commit ID of the commit where you want to add or reply to comments.

   The page for that commit is displayed, along with any comments.

1. To add a comment, do one of the following:
   + To add a general comment, in **Comments on changes**, enter your comment, and then choose **Save**. You can use [Markdown](https://en.wikipedia.org/wiki/Markdown), or you can enter your comment in plaintext.  
![\[A general comment on the changes in a commit.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commenting-changecomment.png)
   + To add a comment to a file in the commit, find the name of the file. Choose **Comment on file**, enter your comment, and then choose **Save**.   
![\[Adding a comment on a file in a commit.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commenting-addfilecomment.png)
   + To add a comment to a changed line in the commit, go to the line where the change appears. Choose the comment bubble ![\[The comment bubble icon that that indicates that you can leave a comment on that line of code.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commentbubble.png), enter your comment, and then choose **Save**.   
![\[Adding a comment on a line in a commit.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commenting-addlinecomment.png)
**Note**  
You can edit your comment after you have saved it. You can also delete its contents. The comment will remain with a message saying that the contents have been deleted. Consider using the **Preview markdown** mode for your comment before you save it.

1. To reply to comments on a commit, choose **Reply**. To reply to a comment with an emoji, choose the emoji you want from the list. You can only choose one emoji per comment. If you want to change your emoji reaction, choose a different one from the list, or choose **None** to remove your reaction.  
![\[Adding replies and emoji reactions to a comment.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commenting-commenttab.png)

### Add and reply to comments when comparing two commit specifiers
<a name="how-to-commit-comment-console-compare"></a>

You can add comments to a comparison between branches, tags, or commits.

**To add or reply to comments when comparing commit specifiers**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the repository where you want to compare commits, branches, or tagged commits. 

1. In the navigation pane, choose **Commits**, and then choose the **Compare commits** tab.  
![\[Compare any two commit specifiers\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-compare-1.png)

1. Use the **Destination** and **Source** fields to compare two commit specifiers. Use the drop-down lists or paste in commit IDs. Choose **Compare**.  
![\[A sample result when comparing a commit ID to a branch\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-compare-4.png)

1. Do one or more of the following:
   + To add comments to files or lines, choose the comment bubble ![\[The comment bubble icon that that indicates that you can leave a comment on that line of code.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-commentbubble.png).
   + To add general comments on the compared changes, go to **Comments on changes**.

## View, add, update, and reply to commments (AWS CLI)
<a name="how-to-commit-comment-cli"></a>

You can view, add, reply, update, and delete the contents of a comment by running the following commands:
+ To view the comments on the comparison between two commits, run **[get-comments-for-compared-commit](#how-to-commit-comment-cli-get-comments)**.
+ To view details on a comment, run [**get-comment**](#how-to-commit-comment-cli-get-comment-info).
+ To delete the contents of a comment that you created, run [**delete-comment-content**](#how-to-commit-comment-cli-commit-delete).
+ To create a comment on the comparison between two commits, run [**post-comment-for-compared-commit**](#how-to-commit-comment-cli-comment).
+ To update a comment, run [**update-comment**](#how-to-commit-comment-cli-commit-update).
+ To reply to a comment, run [**post-comment-reply**](#how-to-commit-comment-cli-commit-reply).
+ To reply to a comment with an emoji, run [**put-comment-reaction**](#how-to-commit-comment-cli-commit-reply-emoji).
+ To view emoji reactions to a comment, run [**get-comment-reactions**](#how-to-commit-comment-cli-commit-emoji-view).

### To view comments on a commit
<a name="how-to-commit-comment-cli-get-comments"></a>

1. Run the **get-comments-for-compared-commit** command, specifying:
   + The name of the CodeCommit repository (with the `--repository-name` option).
   + The full commit ID of the after commit, to establish the directionality of the comparison (with the `--after-commit-id option`).
   + The full commit ID of the before commit, to establish the directionality of the comparison (with the `--before-commit-id` option). 
   + (Optional) An enumeration token to return the next batch of the results (with the `--next-token` option).
   + (Optional) A non-negative integer to limit the number of returned results (with the `--max-results` option).

   For example, to view comments made on the comparison between two commits in a repository named *MyDemoRepo*:

   ```
   aws codecommit get-comments-for-compared-commit --repository-name MyDemoRepo --before-commit-id 6e147360EXAMPLE --after-commit-id 317f8570EXAMPLE
   ```

1. If successful, this command produces output similar to the following:

   ```
   {
      "commentsForComparedCommitData": [ 
         { 
            "afterBlobId": "1f330709EXAMPLE",
            "afterCommitId": "317f8570EXAMPLE",
            "beforeBlobId": "80906a4cEXAMPLE",
            "beforeCommitId": "6e147360EXAMPLE",
            "comments": [ 
               { 
                  "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
                  "clientRequestToken": "123Example",
                  "commentId": "ff30b348EXAMPLEb9aa670f",
                  "content": "Whoops - I meant to add this comment to the line, not the file, but I don't see how to delete it.",
                  "creationDate": 1508369768.142,
                  "deleted": false,
                  "CommentId": "123abc-EXAMPLE",
                  "lastModifiedDate": 1508369842.278,
                  "callerReactions": [],
                  "reactionCounts": 
                   {
                     "SMILE" : 6,
                     "THUMBSUP" : 1
                   }
               },
               {
                  "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
                  "clientRequestToken": "123Example",
                  "commentId": "553b509bEXAMPLE56198325",
                  "content": "Can you add a test case for this?",
                  "creationDate": 1508369612.240,
                  "deleted": false,
                  "commentId": "456def-EXAMPLE",
                  "lastModifiedDate": 1508369612.240,
                  "callerReactions": [],
                  "reactionCounts": 
                   {
                     "THUMBSUP" : 2
                   }
                }
            ],
            "location": { 
               "filePath": "cl_sample.js",
               "filePosition": 1232,
               "relativeFileVersion": "after"
            },
            "repositoryName": "MyDemoRepo"
         }
      ],
      "nextToken": "exampleToken"
   }
   ```

### To view details of a comment on a commit
<a name="how-to-commit-comment-cli-get-comment-info"></a>

1. Run the **get-comment** command, specifying the system-generated comment ID. For example:

   ```
   aws codecommit get-comment --comment-id ff30b348EXAMPLEb9aa670f
   ```

1. If successful, this command returns output similar to the following:

   ```
   {
      "comment": { 
         "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
         "clientRequestToken": "123Example",
         "commentId": "ff30b348EXAMPLEb9aa670f",
         "content": "Whoops - I meant to add this comment to the line, but I don't see how to delete it.",
         "creationDate": 1508369768.142,
         "deleted": false,
         "commentId": "",
         "lastModifiedDate": 1508369842.278,
         "callerReactions": [],
         "reactionCounts": 
            {
              "SMILE" : 6,
              "THUMBSUP" : 1
            }
      }
   }
   ```

### To delete the contents of a comment on a commit
<a name="how-to-commit-comment-cli-commit-delete"></a>

1. Run the **delete-comment-content** command, specifying the system-generated comment ID. For example:

   ```
   aws codecommit delete-comment-content --comment-id ff30b348EXAMPLEb9aa670f
   ```
**Note**  
You can only delete the content of a comment if you have the AWSCodeCommitFullAccess policy applied, or if you have the `DeleteCommentContent` permission set to **Allow**.

1. If successful, this command produces output similar to the following:

   ```
   {
      "comment": { 
         "creationDate": 1508369768.142,  
         "deleted": true,
         "lastModifiedDate": 1508369842.278,
         "clientRequestToken": "123Example",
         "commentId": "ff30b348EXAMPLEb9aa670f",
         "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
         "callerReactions": [],
         "reactionCounts": 
            {
              "CLAP" : 1
            }
      }
   }
   ```

### To create a comment on a commit
<a name="how-to-commit-comment-cli-comment"></a>

1. Run the **post-comment-for-compared-commit** command, specifying:
   + The name of the CodeCommit repository (with the `--repository-name` option).
   + The full commit ID of the after commit, to establish the directionality of the comparison (with the `--after-commit-id `option).
   + The full commit ID of the before commit, to establish the directionality of the comparison (with the `--before-commit-id` option). 
   + A unique, client-generated idempotency token (with the **--client-request-token** option).
   + The content of your comment (with the **--content** option).
   + A list of location information about where to place the comment, including:
     + The name of the file being compared, including its extension and subdirectory, if any (with the **filePath** attribute).
     + The line number of the change within a compared file (with the **filePosition** attribute).
     + Whether the comment on the change is before or after in the comparison between the source and destination branches (with the **relativeFileVersion** attribute).

   For example, to add the comment *"Can you add a test case for this?"* on the change to the *cl\$1sample.js* file in the comparison between two commits in a repository named *MyDemoRepo*:

   ```
   aws codecommit post-comment-for-compared-commit --repository-name MyDemoRepo --before-commit-id 317f8570EXAMPLE --after-commit-id 5d036259EXAMPLE --client-request-token 123Example --content "Can you add a test case for this?" --location filePath=cl_sample.js,filePosition=1232,relativeFileVersion=AFTER   
   ```

1. If successful, this command produces output similar to the following:

   ```
   { 
            "afterBlobId": "1f330709EXAMPLE",
            "afterCommitId": "317f8570EXAMPLE",
            "beforeBlobId": "80906a4cEXAMPLE",
            "beforeCommitId": "6e147360EXAMPLE",
            "comment": {
                  "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
                  "clientRequestToken": "",
                  "commentId": "553b509bEXAMPLE56198325",
                  "content": "Can you add a test case for this?",
                  "creationDate": 1508369612.203,
                  "deleted": false,
                  "commentId": "abc123-EXAMPLE",
                  "lastModifiedDate": 1508369612.203,
                  "callerReactions": [],
                  "reactionCounts": []
                },
                "location": { 
                  "filePath": "cl_sample.js",
                  "filePosition": 1232,
                  "relativeFileVersion": "AFTER"
                },
            "repositoryName": "MyDemoRepo"
    }
   ```

### To update a comment on a commit
<a name="how-to-commit-comment-cli-commit-update"></a>

1. Run the **update-comment** command, specifying the system-generated comment ID and the content to replace any existing content. 

   For example, to add the content *"Fixed as requested. I'll update the pull request."* to a comment with an ID of *442b498bEXAMPLE5756813*:

   ```
   aws codecommit update-comment --comment-id 442b498bEXAMPLE5756813 --content "Fixed as requested. I'll update the pull request."  
   ```

1. If successful, this command produces output similar to the following:

   ```
   { 
       "comment": {
           "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
           "clientRequestToken": "",
           "commentId": "442b498bEXAMPLE5756813",
           "content": "Fixed as requested. I'll update the pull request.",
           "creationDate": 1508369929.783,
           "deleted": false,
           "lastModifiedDate": 1508369929.287,
           "callerReactions": [],
           "reactionCounts": 
             {
               "THUMBSUP" : 2
             }
       }
    }
   ```

### To reply to a comment on a commit
<a name="how-to-commit-comment-cli-commit-reply"></a>

1. To post a reply to a comment in a pull request, run the **post-comment-reply** command, specifying:
   + The system-generated ID of the comment to which you want to reply (with the **--in-reply-to** option).
   + A unique, client-generated idempotency token (with the **--client-request-token** option).
   + The content of your reply (with the **--content** option). 

    For example, to add the reply *"Good catch. I'll remove them."* to the comment with the system-generated ID of *abcd1234EXAMPLEb5678efgh*: 

   ```
   aws codecommit post-comment-reply --in-reply-to abcd1234EXAMPLEb5678efgh --content "Good catch. I'll remove them." --client-request-token 123Example
   ```

1. If successful, this command produces output similar to the following:

   ```
   { 
       "comment": {
           "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
           "clientRequestToken": "123Example",
           "commentId": "442b498bEXAMPLE5756813",
           "content": "Good catch. I'll remove them.",
           "creationDate": 1508369829.136,
           "deleted": false,
           "CommentId": "abcd1234EXAMPLEb5678efgh",
           "lastModifiedDate": 150836912.221,
           "callerReactions": [],
           "reactionCounts": []
       }
    }
   ```

### To reply to a comment on a commit with an emoji
<a name="how-to-commit-comment-cli-commit-reply-emoji"></a>

1. To reply to a comment in a pull request with an emoji, or to change the value of your emoji reaction, run the **put-comment-reaction** command, specifying:
   + The system-generated ID of the comment to which you want to reply with an emoji.
   + The value of the reaction you want to add or update. Acceptable values include supported emojis, shortcodes, and Unicode values.<a name="emoji-reaction-table"></a>

   The following values are supported for emojis in CodeCommit:  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/codecommit/latest/userguide/how-to-commit-comment.html)

    For example, to add the emoji *:thumbsup:* to the comment with the system-generated ID of *abcd1234EXAMPLEb5678efgh*: 

   ```
   aws codecommit put-comment-reaction --comment-id abcd1234EXAMPLEb5678efgh --reaction-value :thumbsup: 
   ```

1. If successful, this command produces no output.

### To view emoji reactions to a comment
<a name="how-to-commit-comment-cli-commit-emoji-view"></a>

1. To view emoji reactions to a comment, including the users who reacted with those emojis, run the **get-comment-reactions** command, specifying the system-generated ID of the comment. 

    For example, to view emoji reactions to the comment with the system-generated ID of *abcd1234EXAMPLEb5678efgh*: 

   ```
   aws codecommit get-comment-reactions --comment-id abcd1234EXAMPLEb5678efgh 
   ```

1. If successful, this command produces output similar to the following:

   ```
   {
       "reactionsForComment": {
           [
              {
                   "reaction": {
                       "emoji:"👍",
                       "shortCode": "thumbsup",
                       "unicode": "U+1F44D"
                   },
                   "users": [
                       "arn:aws:iam::123456789012:user/Li_Juan",
                       "arn:aws:iam::123456789012:user/Mary_Major",
                       "arn:aws:iam::123456789012:user/Jorge_Souza"
                   ]
               },
               {
                   "reaction": {
                       "emoji": "👎",
                       "shortCode": "thumbsdown",
                       "unicode": "U+1F44E"
                   },
                   "users": [
                       "arn:aws:iam::123456789012:user/Nikhil_Jayashankar"
                   ]
               },
               {
                   "reaction": {
                       "emoji": "😕",
                       "shortCode": "confused",
                       "unicode": "U+1F615"
                   },
                   "users": [
                       "arn:aws:iam::123456789012:user/Saanvi_Sarkar"
                   ]
               }
           ]
       }
   }
   ```

# Create a Git tag in AWS CodeCommit
<a name="how-to-create-tag"></a>

You can use a Git tag to mark a commit with a label that helps other repository users understand its importance. To create a Git tag in a CodeCommit repository, you can use Git from a local repo connected to the CodeCommit repository. After you have created a Git tag in the local repo, you can use **git push --tags** to push it to the CodeCommit repository. 

For more information, see [View tag details](how-to-view-tag-details.md).

## Use Git to create a tag
<a name="how-to-create-tag-git"></a>

Follow these steps to use Git from a local repo to create a Git tag in a CodeCommit repository.

In these steps, we assume that you have already connected the local repo to the CodeCommit repository. For instructions, see [Connect to a repository](how-to-connect.md).

1. Run the **git tag *new-tag-name* *commit-id*** command, where *new-tag-name* is the new Git tag's name and *commit-id* is the ID of the commit to associate with the Git tag.

   For example, the following command creates a Git tag named `beta` and associates it with the commit ID `dc082f9a...af873b88`:

   ```
   git tag beta dc082f9a...af873b88
   ```

1. To push the new Git tag from the local repo to the CodeCommit repository, run the **git push *remote-name* *new-tag-name*** command, where *remote-name* is the name of the CodeCommit repository and *new-tag-name* is the name of the new Git tag. 

   For example, to push a new Git tag named `beta` to a CodeCommit repository named `origin`:

   ```
   git push origin beta
   ```

**Note**  
To push all new Git tags from your local repo to the CodeCommit repository, run **git push --tags**.  
To ensure your local repo is updated with all of the Git tags in the CodeCommit repository, run **git fetch** followed by **git fetch --tags**.

For more options, see your Git documentation.

# View Git tag details in AWS CodeCommit
<a name="how-to-view-tag-details"></a>

In Git, a tag is a label you can apply to a reference like a commit to mark it with information that might be important to other repository users. For example, you might tag the commit that was the beta release point for a project with the tag **beta**. For more information, see [Use Git to create a tag](how-to-create-tag.md#how-to-create-tag-git). Git tags are different from repository tags. For more information about how to use repository tags, see [Add a tag to a repository](how-to-tag-repository-add.md).

You can use the AWS CodeCommit console to view information about Git tags in your repository, including the date and commit message of the commit referenced by each Git tag. From the console, you can compare the commit referenced by the tag with the head of the default branch of your repository. Like any other commit, you can also view the code at the point of that Git tag.

You can also use Git from your terminal or command line to view details about Git tags in a local repo. 

**Topics**
+ [View tag details (console)](#how-to-view-tag-details-console)
+ [View Git tag details (Git)](#how-to-view-tag-details-git)

## View tag details (console)
<a name="how-to-view-tag-details-console"></a>

Use the AWS CodeCommit console to quickly view a list of Git tags for your repository and details about the commits referenced by the Git tags.

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the name of the repository where you want to view tags. 

1. In the navigation pane, choose **Git tags**.  
![\[A view of tags in a repository.\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/codecommit-tags-view.png)

1. Do one of the following:
   + To view the code as it was at that commit, choose the Git tag name.
   + To view details of the commit, including the full commit message, committer, and author, choose the abbreviated commit ID.

## View Git tag details (Git)
<a name="how-to-view-tag-details-git"></a>

To use Git to view details about Git tags in a local repo, run one of the following commands:
+ [git tag](#how-to-view-tag-details-git-tag) to view a list of Git tag names.
+ [git show](#how-to-view-tag-details-git-show) to view information about a specific Git tag.
+ [git ls-remote](#how-to-view-tag-details-git-remote) to view information about Git tags in a CodeCommit repository.

**Note**  
To ensure that your local repo is updated with all of the Git tags in the CodeCommit repository, run **git fetch** followed by **git fetch --tags**.

In the following steps, we assume that you have already connected the local repo to a CodeCommit repository. For instructions, see [Connect to a repository](how-to-connect.md).

### To view a list of Git tags in a local repo
<a name="how-to-view-tag-details-git-tag"></a>

1. Run the **git tag** command:

   ```
   git tag
   ```

1. If successful, this command produces output similar to the following:

   ```
   beta
   release
   ```
**Note**  
If no tags have been defined, **git tag** returns nothing.

For more options, see your Git documentation.

### To view information about a Git tag in a local repo
<a name="how-to-view-tag-details-git-show"></a>

1. Run the **git show *tag-name*** command. For example, to view information about a Git tag named `beta`, run:

   ```
   git show beta
   ```

1. If successful, this command produces output similar to the following:

   ```
   commit 317f8570...ad9e3c09
   Author: John Doe <johndoe@example.com>
   Date:   Tue Sep 23 13:49:51 2014 -0700
   
       Added horse.txt
   
   diff --git a/horse.txt b/horse.txt
   new file mode 100644
   index 0000000..df42ff1
   --- /dev/null
   +++ b/horse.txt
   @@ -0,0 +1 @@
   +The horse (Equus ferus caballus) is one of two extant subspecies of Equus ferus
   \ No newline at end of file
   ```
**Note**  
To exit the output of the Git tag information, type **:q**.

For more options, see your Git documentation.

### To view information about Git tags in a CodeCommit repository
<a name="how-to-view-tag-details-git-remote"></a>

1. Run the **git ls-remote --tags** command.

   ```
   git ls-remote --tags
   ```

1. If successful, this command produces as output a list of the Git tags in the CodeCommit repository: 

   ```
   129ce87a...70fbffba    refs/tags/beta
   785de9bd...59b402d8    refs/tags/release
   ```

   If no Git tags have been defined, **git ls-remote --tags** returns a blank line.

For more options, see your Git documentation.

# Delete a Git tag in AWS CodeCommit
<a name="how-to-delete-tag"></a>

To delete a Git tag in a CodeCommit repository, use Git from a local repo connected to the CodeCommit repository. .

## Use Git to delete a Git tag
<a name="how-to-delete-tag-git"></a>

Follow these steps to use Git from a local repo to delete a Git tag in a CodeCommit repository.

These steps are written with the assumption that you have already connected the local repo to the CodeCommit repository. For instructions, see [Connect to a repository](how-to-connect.md).

1. To delete the Git tag from the local repo, run the **git tag -d *tag-name*** command where *tag-name* is the name of the Git tag you want to delete.
**Tip**  
To get a list of Git tag names, run **git tag**.

   For example, to delete a Git tag in the local repo named `beta`:

   ```
   git tag -d beta
   ```

1. To delete the Git tag from the CodeCommit repository, run the **git push *remote-name* --delete *tag-name*** command where *remote-name* is the nickname the local repo uses for the CodeCommit repository and *tag-name* is the name of the Git tag you want to delete from the CodeCommit repository.
**Tip**  
To get a list of CodeCommit repository names and their URLs, run the **git remote -v** command.

   For example, to delete a Git tag named `beta` in the CodeCommit repository named `origin`:

   ```
   git push origin --delete beta
   ```