

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 AWS CodeCommit 儲存庫中使用遞交
<a name="commits"></a>

遞交是儲存庫的內容和內容變更的快照。每當使用者遞交和推送變更時，該資訊就會儲存和存放起來。因此，儲存的資訊也包括誰遞交變更、遞交的日期和時間，以及在遞交時所做的變更。您也可以將遞交加上標籤，以輕鬆地識別特定的遞交。在 CodeCommit 中，您可以：
+ 檢閱遞交。
+ 在圖表中檢視遞交的歷史記錄。
+ 將遞交與其父系或另一個指標做比較。
+ 對遞交新增註解，並回覆其他人所做的註解。

![\[對遞交中變更的行新增註解。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-addlinecomment.png)


您必須先設定本機電腦以連線至儲存庫，才能將遞交推送至 CodeCommit 儲存庫。如需最簡單的方式，請參閱[對於使用 Git 登入資料的 HTTPS 使用者](setting-up-gc.md)。

如需有關在 CodeCommit 中使用儲存庫其他層面的資訊，請參閱 [使用儲存庫](repositories.md)、[使用檔案](files.md)、[使用提取請求](pull-requests.md)、 [使用分支](branches.md)和 [使用使用者偏好設定](user-preferences.md)。

**Topics**
+ [在 中建立遞交 AWS CodeCommit](how-to-create-commit.md)
+ [在 中檢視遞交詳細資訊 AWS CodeCommit](how-to-view-commit-details.md)
+ [比較 中的遞交 AWS CodeCommit](how-to-compare-commits.md)
+ [在 中對遞交的註解 AWS CodeCommit](how-to-commit-comment.md)
+ [在 中建立 Git 標籤 AWS CodeCommit](how-to-create-tag.md)
+ [在 中檢視 Git 標籤詳細資訊 AWS CodeCommit](how-to-view-tag-details.md)
+ [在 中刪除 Git 標籤 AWS CodeCommit](how-to-delete-tag.md)

# 在 中建立遞交 AWS CodeCommit
<a name="how-to-create-commit"></a>

當您為新儲存庫建立第一個遞交時，您可以使用 AWS CLI 和 **put-file**命令。這會建立第一個遞交，並允許您為新儲存庫建立和指定預設分支。您可以使用 Git 或 AWS CLI 在 CodeCommit 儲存庫中建立遞交。如果本機儲存庫連接到 CodeCommit 儲存庫，您可以使用 Git 將遞交從本機儲存庫推送到 CodeCommit 儲存庫。若要直接在 CodeCommit 主控台中建立遞交，請參閱 [建立檔案或將檔案新增至 AWS CodeCommit 儲存庫](how-to-create-file.md)和 [編輯 AWS CodeCommit 儲存庫中檔案的內容](how-to-edit-file.md)。

**注意**  
最佳實務是建議您使用 AWS CLI、Git 和其他軟體的最新支援版本。如果您使用 AWS CLI，請確定已安裝最新版本，以確保您使用的版本包含 `create-commit`命令。

**Topics**
+ [使用 建立儲存庫的第一個遞交 AWS CLI](#how-to-create-first-commit)
+ [使用 Git 用戶端建立遞交](#how-to-create-commit-git)
+ [使用 建立遞交 AWS CLI](#how-to-create-commit-cli)

## 使用 建立儲存庫的第一個遞交 AWS CLI
<a name="how-to-create-first-commit"></a>

您可以使用 AWS CLI 和 `put-file`命令來建立儲存庫的第一個遞交。使用 **put-file**會建立第一個遞交，將檔案新增至空白儲存庫，並使用您指定的名稱建立分支。它會指定新的分支做為儲存庫的預設分支。

**注意**  
若要搭配 CodeCommit 使用 AWS CLI 命令，請安裝 AWS CLI。如需詳細資訊，請參閱[命令列參考](cmd-ref.md)。<a name="create-first-commit"></a>

## 使用 建立儲存庫的第一個遞交 AWS CLI


1. 在本機電腦上，建立您要新增為 CodeCommit 儲存庫第一個檔案的檔案。常見的做法是建立 `README.md` Markdown 檔案，向其他儲存庫使用者解釋此儲存庫的用途。如果您包含`README.md`檔案，檔案的內容會自動顯示在 CodeCommit 主控台中儲存庫的**程式碼**頁面底部。

1. 在終端機或命令列，執行 **put-file** 命令，並指定：
   + 您要新增第一個檔案的儲存庫名稱。
   + 您要建立為預設分支的分支名稱。
   + 檔案的本機位置。用於此位置的語法因您的本機作業系統而有所不同。
   + 您要新增的檔案名稱，包括更新檔案儲存在儲存庫中的路徑。
   + 您要與此檔案建立關聯的使用者名稱和電子郵件。
   + 說明為何新增此檔案的遞交訊息。

   使用者名稱、電子郵件地址和遞交訊息是選用的，但可協助其他使用者知道誰進行了變更以及原因。如果您未提供使用者名稱，CodeCommit 預設為使用您的 IAM 使用者名稱或主控台登入衍生作為作者名稱。

   例如，若要將名為 *README.md* 的檔案與範例 base 6 編碼的檔案內容新增至名為 *MyDemoRepo* 的儲存庫，以及名為*開發*的分支：

   ```
   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."
   ```

   如果此命令成功執行，您會看到類似如下的輸出傳回：

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

## 使用 Git 用戶端建立遞交
<a name="how-to-create-commit-git"></a>

您可以使用安裝在本機電腦上的 Git 用戶端來建立遞交，然後將這些遞交推送到您的 CodeCommit 儲存庫。

1. 完成必要條件，包括[設定 ](setting-up.md)。
**重要**  
如果尚未完成設定，您無法使用 Git 連接到或遞交至儲存庫。

1. 確定您是在正確的分支中建立遞交。若要查看可用的分支清單，並了解您目前設定使用的分支，請執行 **git branch**。將會顯示所有分支。您目前的分支旁會顯示星號 (`*`)。若要切換到不同的分支，請執行 **git checkout *branch-name***。如果這是您的第一個遞交，請執行 **git config **命令來設定您的 Git 用戶端，以建立具有您要用於該分支之名稱的初始分支。例如，如果您希望預設分支具有名稱*開發*：

   ```
   git config --local init.defaultBranch development
   ```
**提示**  
此命令僅適用於 Git v.2.28 和更新版本。  
您也可以執行此命令，**development**將所有新建立的儲存庫的預設分支名稱設定為 ：  

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

1. 對分支進行變更 (例如，新增、修改或刪除檔案)。

   例如，在本機儲存庫中，`bird.txt`使用下列文字建立名為 的檔案：

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

1. 執行 **git status**，應該會指出 `bird.txt` 尚未在任何擱置中包含的遞交：

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

1. 執行 **git add bird.txt** 以在擱置中遞交中包含新的檔案。

1. 如果您再次執行 **git status**，應該會看到類似如下的輸出：這表示 `bird.txt` 現在已屬於擱置中遞交或暫存供遞交：

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

1. 若要完成遞交，請執行 **git commit** 搭配 `-m` 選項 (例如，** git commit -m "*Adding bird.txt to the repository.*"**)。`-m` 選項會建立遞交訊息。

1. 如果您再次執行 **git status**，應該會看到類似如下的輸出：它表示遞交已準備好從本機儲存庫推送到 CodeCommit 儲存庫：

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

1. 在您將最終遞交從本機儲存庫推送至 CodeCommit 儲存庫之前，您可以執行 來查看要推送的內容**git diff --stat *remote-name*/*branch-name***，其中 *remote-name* 是本機儲存庫用於 CodeCommit 儲存庫的別名，*而 branch-name* 是要比較的分支名稱。
**提示**  
若要取得別名，請執行 **git remote**。若要取得分支名稱的清單，請執行 **git branch**。目前的分支旁會顯示星號 (`*`)。您也可以執行 **git status** 以取得目前的分支名稱。
**注意**  
如果您複製儲存庫，從本機儲存庫的角度來看，*remote-name* 不是 CodeCommit 儲存庫的名稱。複製儲存庫時，*remote-name* 會自動設定為 `origin`。

   例如，**git diff --stat origin/main** 會顯示與下列類似的輸出：

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

   輸出假設您已將本機儲存庫連線至 CodeCommit 儲存庫。(如需指示，請參閱[連接到儲存庫](how-to-connect.md)。)

1. 當您準備好將遞交從本機儲存庫推送至 CodeCommit 儲存庫時，請執行 **git push *remote-name* *branch-name***，其中 *remote-name* 是本機儲存庫用於 CodeCommit 儲存庫的別名，而 *branch-name* 是要推送至 CodeCommit 儲存庫的分支名稱。

   例如，執行 **git push origin main** 會顯示與下列類似的輸出：

   針對 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
   ```

   針對 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
   ```
**提示**  
如果您將 `-u` 選項新增至 **git push** (例如，**git push -u origin main**)，則未來只需執行 **git push**，因為已設定上游追蹤資訊。若要取得上游追蹤資訊，請執行 **git remote show *remote-name*** (例如，**git remote show origin**)。

如需更多選項，請參閱 Git 文件。

## 使用 建立遞交 AWS CLI
<a name="how-to-create-commit-cli"></a>

您可以使用 AWS CLI 和 `create-commit`命令，在指定的分支頂端建立儲存庫的遞交。您也可以建立未參照的合併遞交來代表合併兩個遞交指標的結果。如需詳細資訊，請參閱[建立未參照遞交](how-to-resolve-conflict-pull-request.md#create-unreferenced-merge-commit)。

**注意**  
若要搭配 CodeCommit 使用 AWS CLI 命令，請安裝 AWS CLI。如需詳細資訊，請參閱[命令列參考](cmd-ref.md)。<a name="create-commit"></a>

**建立遞交**

1. 在本機電腦上，進行您要遞交至 CodeCommit 儲存庫的變更。

1. 在終端機或命令列，執行 **create-commit** 命令，並指定：
   + 您要遞交變更的儲存庫。
   + 您要遞交變更的分支。
   + 對該分支所進行最新遞交的完整遞交 ID，也稱為頂端或標頭遞交，或父遞交 ID。
   + 如果您所做的變更會刪除資料夾的內容，是否保留任何空的資料夾。根據預設，此值為 false。
   + 您想要新增、變更或刪除的檔案的相關資訊。
   + 要與這些變更建立關聯的使用者名稱和電子郵件。
   + 用以說明您為什麼做這些變更的遞交訊息。

   使用者名稱、電子郵件地址和遞交訊息是選用的，但可協助其他使用者知道進行變更的人員及原因。如果您未提供使用者名稱，CodeCommit 預設為使用您的 IAM 使用者名稱或主控台登入衍生作為作者名稱。

   例如，若要為將`README.md`檔案新增至*主*分支中名為 *MyDemoRepo* 的儲存庫建立遞交。檔案的內容位於 Base64 中，並讀取「歡迎使用我的團隊儲存庫！」：

   ```
   aws codecommit create-commit --repository-name MyDemoRepo --branch-name main --parent-commit-id 4c925148EXAMPLE --put-files "filePath=README.md,fileContent=V2VsY29tZSB0byBvdXIgdGVhbSByZXBvc2l0b3J5IQo="
   ```
**提示**  
若要取得父遞交 ID，請執行 [get-branch](how-to-view-branch-details.md#how-to-view-branch-details-cli-details) 命令。

   如果此命令成功執行，您會看到類似如下的輸出傳回：

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

   若要建立對名為 *file1.py* 和 *file2.txt* 的檔案進行變更的遞交， 會將檔案從 *picture.png* 重新命名為 *image1.png*，並將其從名為*圖片*的目錄移至名為 *ExampleSolution.py* 的目錄、*映像*，並在名為 *MyFeatureBranch* 的分支中刪除名為 *MyDemoRepo* 的檔案，該分支的最近遞交 ID 為 *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"
   ```
**注意**  
**--put-files** 區段的語法會根據您的作業系統而有所不同。上述範例已針對具有 Bash 模擬器的 Linux、macOS 或 Unix 使用者和 Windows 使用者進行最佳化。採用命令列或 Powershell 的 Windows 使用者，應該使用該系統適用的語法。

   如果此命令成功執行，您會看到類似如下的輸出傳回：

   ```
   {
      "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"
           }
       ]
   }
   ```

# 在 中檢視遞交詳細資訊 AWS CodeCommit
<a name="how-to-view-commit-details"></a>

您可以使用 AWS CodeCommit 主控台來瀏覽儲存庫中的遞交歷史記錄。這可協助您識別儲存庫中進行的變更，包括：
+ 變更何時以及由誰進行。
+ 特定遞交何時合併到分支。

檢視分支遞交的歷史記錄可能也有助於了解分支之間的差異。如果您使用標記，也可以快速地檢視加上標籤的遞交和該標記遞交的父項。在命令列，您可以使用 Git 檢視本機儲存庫或 CodeCommit 儲存庫中遞交的詳細資訊。

## 瀏覽儲存庫中的遞交
<a name="how-to-view-commit-details-console"></a>

您可以使用 AWS CodeCommit 主控台來瀏覽遞交至儲存庫的歷史記錄。您也可以隨著時間檢視儲存庫中遞交及其分支的圖表。這可協助您了解儲存庫的歷史記錄，包括進行變更的時間。

**注意**  
使用 **git rebase** 命令來重設儲存庫的基準會變更儲存庫的歷史記錄，這可能造成遞交不按順序顯示。如需詳細資訊，請參閱 [Git 分支重設基準](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)或您的 Git 文件。

**Topics**
+ [瀏覽儲存庫的遞交歷史記錄](#how-to-view-commit-details-console-history)
+ [檢視儲存庫遞交歷史記錄的圖表](#how-to-view-commit-details-console-visualizer)

### 瀏覽儲存庫的遞交歷史記錄
<a name="how-to-view-commit-details-console-history"></a>

您可以瀏覽特定分支或儲存庫標籤的遞交歷史記錄，包含遞交者和遞交訊息的詳細資訊。您也可以檢視遞交的程式碼。

**瀏覽遞交的歷史記錄**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要檢閱遞交歷史記錄的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**。在遞交歷史記錄檢視中，會顯示預設分支中儲存庫遞交的歷史記錄，以遞交日期的相反時間順序顯示。日期與時間採用國際標準時間 (UTC)。您可以檢視不同分支遞交的歷史記錄，方法是選擇檢視選取器按鈕，然後從清單中選擇分支。如果您使用的是您的儲存庫中的標籤，您可以透過在檢視選取器按鈕中選擇該標籤，以檢視具有特定標籤的遞交和及父系。  
![\[主控台中的遞交檢視\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commit-list.png)

1. 若要檢視遞交與其父系之間的差異，並選擇遞交的 ID 來查看對於變更的相關評論。如需詳細資訊，請參閱[將遞交與其父項進行比較](how-to-compare-commits.md#how-to-compare-commits-parent)及[對遞交做註解](how-to-commit-comment.md)。若要檢視遞交與任何其他遞交指標 (包括分支、標籤或遞交 ID) 之間的差異，請參閱[比較任兩個遞交指標](how-to-compare-commits.md#how-to-compare-commits-compare)。

1. 執行下列其中一項或多項：
   + 若要檢視進行變更的日期和時間，請將滑鼠的游標移到遞交日期上。
   + 若要檢視完整遞交 ID，請複製然後將它貼到文字編輯器或其他位置。若要複製，請選擇**複製 ID**。
   + 若要檢視程式碼在遞交時的狀態，請選擇 **Browse (瀏覽)**。儲存庫在該遞交時的內容會顯示在 **Code (程式碼)** 檢視中。檢視選取器按鈕會顯示縮寫的遞交 ID 而非分支或標籤。

### 檢視儲存庫遞交歷史記錄的圖表
<a name="how-to-view-commit-details-console-visualizer"></a>

您可以檢視對儲存庫所做的遞交圖表。**Commit Visualizer** 檢視是對儲存庫的分支所進行所有遞交的有向無環圖 (DAG) 呈現。此圖形呈現可協助您了解新增或合併遞交和關聯功能的時間。它也可以協助您了解與其他變更相關的變更是何時進行。

**注意**  
在遞交圖表中，使用向前快轉方法合併的遞交不會以單獨線條的形式顯示。

**檢視遞交的圖表**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要檢視遞交圖表的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**，然後選擇 **Commit visualizer (遞交視覺化工具)** 索引標籤。  
![\[主控台的儲存庫圖表檢視\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-cv-complex1.png)

   在遞交圖表中，縮寫遞交 ID 和每個遞交訊息的主旨會出現在圖表中的該點旁。
**注意**  
圖表在一頁上最多可以顯示 35 個分支。如果超過 35 個分支，則圖表會太複雜而無法顯示。您可以透過兩個方式將檢視簡化：  
使用檢視選取器按鈕來顯示特定分支的圖形。
透過貼上完整的遞交 ID 至搜尋方塊，從該遞交轉譯圖形。

1. 若要從遞交轉譯圖形，請在圖形中選擇與該遞交對應的點。檢視選取器按鈕會變更為縮寫的遞交 ID。  
![\[從特定遞交轉譯了新圖形\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-cv-commit.png)

## 檢視遞交詳細資訊 (AWS CLI)
<a name="how-to-view-commit-details-cli"></a>

Git 可讓您檢視遞交的詳細資訊。您也可以執行下列命令 AWS CLI ，使用 檢視本機儲存庫或 CodeCommit 儲存庫中遞交的詳細資訊：
+ 若要檢視一個遞交的相關資訊，請執行 **[aws codecommit get-commit](#how-to-view-commit-details-cli-commit)**。
+ 若要檢視多個遞交的相關資訊，請執行 **[aws codecommit batch-get-commits](#how-to-view-commit-details-cli-batch-get-commits)**。
+ 若要檢視合併遞交的相關資訊，請執行 **[aws codecommit get-merge-commit](#how-to-view-commit-details-cli-merge-commit)**。
+ 若要檢視遞交指標 (分支、標籤、HEAD 或其他完整參考，例如遞交 ID) 的變更的相關資訊，請執行 **[aws codecommit get-differences](#how-to-view-commit-details-cli-differences)**。
+ 若要檢視儲存庫中 Git Blob 物件的 base64 編碼內容，請執行 **[aws codecommit get-blob](#how-to-view-commit-details-cli-blob)**。

### 檢視遞交的詳細資訊
<a name="how-to-view-commit-details-cli-commit"></a>

1. 執行 **aws codecommit get-commit** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + 完整遞交 ID。

   例如，若要在名為 的 CodeCommit 儲存庫`317f8570EXAMPLE`中檢視 ID 為 之遞交的相關資訊`MyDemoRepo`：

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

1. 如果成功，此命令的輸出包含下列：
   + 遞交作者 (如 Git 所設定) 的詳細資訊，包括採用時間戳記格式的日期和國際標準時間 (UTC) 位移。
   + 遞交者 (如 Git 所設定) 的詳細資訊，包括採用時間戳記格式的日期和 UTC 位移。
   + 遞交存在位置的 Git 樹狀目錄 ID。
   + 父遞交的遞交 ID。
   + 遞交訊息。

   以下是基於上述範例命令的一些範例輸出：

   ```
   {
       "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"
       }
   }
   ```

### 檢視合併遞交的相關資訊
<a name="how-to-view-commit-details-cli-merge-commit"></a>

1. 執行 **get-merge-commit** 命令，並指定：
   + 合併來源的遞交指標 (使用 **--source-commit-specifier** 選項)。
   + 合併目的地的遞交指標 (使用 **--destination-commit-specifier** 選項)。
   + 您想要使用的合併選項 (使用 **--merge-option** 選項)。
   + 儲存庫的名稱 (使用 **--repository-name** 選項)。

   例如，若要使用名為 *MyDemoRepo* 的儲存庫中的 *THREE\$1WAY\$1MERGE* 策略，檢視名為 *bugfix-bug1234* 之來源分支與名為 *main* 之目的地分支的合併遞交的相關資訊：

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

1. 如果成功，此命令的輸出會傳回類似如下的資訊：

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

### 檢視多個遞交的相關資訊
<a name="how-to-view-commit-details-cli-batch-get-commits"></a>

1. 執行 **batch-get-commits** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + 您要檢視其資訊的每個遞交的完整遞交 ID 清單。

   例如，若要在名為 的 CodeCommit 儲存庫`4c925148EXAMPLE`中檢視具有 IDs `317f8570EXAMPLE`和 之遞交的相關資訊`MyDemoRepo`：

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

1. 如果成功，此命令的輸出包含下列：
   + 遞交作者 (如 Git 所設定) 的詳細資訊，包括採用時間戳記格式的日期和國際標準時間 (UTC) 位移。
   + 遞交者 (如 Git 所設定) 的詳細資訊，包括採用時間戳記格式的日期和 UTC 位移。
   + 遞交存在位置的 Git 樹狀目錄 ID。
   + 父遞交的遞交 ID。
   + 遞交訊息。

   以下是基於上述範例命令的一些範例輸出：

   ```
   {
       "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"
       }   
   }
   ```

### 檢視遞交指標變更的詳細資訊
<a name="how-to-view-commit-details-cli-differences"></a>

1. 執行 **aws codecommit get-differences** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + 您要取得資訊的遞交指標。只有 `--after-commit-specifier` 為必要。如果您不指定 `--before-commit-specifier`，將會顯示在 `--after-commit-specifier` 時當時的所有檔案。

   例如，若要檢視名為 之 CodeCommit 儲存庫`4c925148EXAMPLE`中 ID IDs 為 之遞交`317f8570EXAMPLE`與 之間差異的相關資訊`MyDemoRepo`：

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

1. 如果成功，此命令的輸出包含下列：
   + 差異的清單，包含變更類型 (A 代表已新增，D 代表已刪除，或 M 代表已修改)。
   + 檔案變更類型的模式。
   + 包含變更的 Git Blob 物件 ID。

   以下是基於上述範例命令的一些範例輸出：

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

### 檢視 Git Blob 物件的詳細資訊
<a name="how-to-view-commit-details-cli-blob"></a>

1. 執行 **aws codecommit get-blob** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + Git Blob 的 ID (使用 `--blob-id ` 選項)。

   例如，若要在名為 的 CodeCommit 儲存庫`2eb4af3bEXAMPLE`中檢視 ID 為 的 Git Blob 相關資訊`MyDemoRepo`： CodeCommit 

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

1. 如果成功，此命令的輸出包含下列：
   + Blob 的 base64 編碼內容，通常是一個檔案。

   例如，前一個命令的輸出應類似以下：

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

## 檢視遞交詳細資訊 (Git)
<a name="how-to-view-commit-details-git"></a>

在遵循這些步驟之前，您應該已將本機儲存庫連線至 CodeCommit 儲存庫並遞交變更。如需說明，請參閱[連接到儲存庫](how-to-connect.md)。

若要顯示最近遞交至儲存庫的變更，請執行 **git show**命令。

```
git show
```

此命令會產生類似下列的輸出：

```
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
```

**注意**  
在此範例和以下範例中，遞交 ID 已縮寫。不會顯示完整的遞交 ID。

若要檢視發生的變更，請使用 **git show** 命令搭配遞交 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.
```

若要查看兩個遞交之間的差異，請執行 **git diff**命令並包含兩個遞交 IDs。

```
git diff ce22850d 4f8c6f9d
```

在此範例中，這兩個遞交之間的差異是已新增了兩個檔案。此命令會產生類似下列的輸出：

```
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
```

若要使用 Git 檢視本機儲存庫中遞交的詳細資訊，請執行 **git log**命令：

```
git log
```

如果此命令成功執行，您會看到類似如下的輸出產生：

```
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
```

若只要顯示遞交 ID 和訊息，請執行 **git log --pretty=oneline** 命令：

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

如果此命令成功執行，您會看到類似如下的輸出產生：

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

如需更多選項，請參閱 Git 文件。

# 比較 中的遞交 AWS CodeCommit
<a name="how-to-compare-commits"></a>

您可以使用 CodeCommit 主控台來檢視 CodeCommit 儲存庫中遞交指標之間的差異。您可以快速檢視遞交與其父系之間的差異。您也可以比較任兩個參考，包括遞交 ID。

**Topics**
+ [將遞交與其父項進行比較](#how-to-compare-commits-parent)
+ [比較任兩個遞交指標](#how-to-compare-commits-compare)

## 將遞交與其父項進行比較
<a name="how-to-compare-commits-parent"></a>

您可以快速檢視遞交與其父系之間的差異，以檢閱遞交訊息、遞交者和變更內容。

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 頁面上，選擇您要檢視遞交與其父系之間差異所在的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**。

1. 選擇清單中任何縮寫的遞交 ID。檢視會變更為顯示其遞交的詳細資訊，包括它與其父遞交之間的差異。  
![\[選擇縮寫的遞交 ID 可顯示此遞交與其父系之間的差異。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commit-changes1.png)

   您可以透過左右並排 (**Split (分割)** 檢視) 或內嵌 (**Unified (統一)** 檢視) 來顯示變更。您也可以隱藏或顯示空格的變更。您也可以新增評論。如需詳細資訊，請參閱[對遞交做註解](how-to-commit-comment.md)。
**注意**  
用於檢視程式碼的偏好設定及其他主控台設定只要有變動，就會儲存為瀏覽器 Cookie。如需詳細資訊，請參閱[使用使用者偏好設定](user-preferences.md)。  
![\[統一檢視中顯示的變更，空格變更會隱藏\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commit-changes2c.png)  
![\[分割檢視中顯示的變更，並在行上加上註解\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-commenttab.png)
**注意**  
 根據行結尾樣式，您的程式碼編輯器和其他因素，您可能看見新增或刪除整行，而不是行中的特定變更。詳細資訊層級符合 **git show** 或 **git diff** 命令中傳回的內容。

1. 若要將遞交與其父系比較，請從 **Commit visualize (遞交視覺化工具)** 索引標籤，選擇縮寫的遞交 ID。將顯示遞交詳細資訊，包括遞交與其父系之間的變更。

## 比較任兩個遞交指標
<a name="how-to-compare-commits-compare"></a>

您可以在 CodeCommit 主控台中檢視任兩個遞交指標之間的差異。遞交指標為參考，例如分支、標籤和遞交 ID。

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 頁面上，選擇您要比較遞交、分支或附加標籤之遞交所在的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**，然後選擇 **Compare commits (比較遞交)**。  
![\[比較任兩個遞交指標\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-compare-1.png)

1. 使用方塊來比較兩個遞交指標。
   + 若要比較分支的頂端，請從清單中選擇分支名稱。這會從用於比較的該分支選取最新的遞交。
   + 若要將遞交與關聯的特定標籤比較，請從清單選擇標籤名稱 (如果有)。這會選取用於比較的之加上標籤的遞交。
   + 若要比較特定的遞交，請在方塊中輸入或貼上遞交 ID。若要取得完整的遞交 ID，請選擇導覽列中的 **Commits (遞交)**，並從清單複製遞交 ID。在**比較遞交**頁面上，將完整的遞交 ID 貼到文字方塊中，然後選擇**使用遞交 ID**。  
![\[比較分支、標籤或遞交 ID\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-compare-2.png)

1. 選取指標之後，選擇 **Compare (比較)**。  
![\[檢視兩個分支之間的比較\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-compare-branches.png)

   您可以透過左右並排 (**Split (分割)** 檢視) 或內嵌 (**Unified (統一)** 檢視) 來顯示差異。您也可以隱藏或顯示空格的變更。

1. 若要清除您的比較選項，請選擇 **Cancel (取消)**。

# 在 中對遞交的註解 AWS CodeCommit
<a name="how-to-commit-comment"></a>

您可以使用 CodeCommit 主控台來評論儲存庫中的遞交，以及檢視和回覆其他使用者對遞交的評論。這可協助您討論對儲存庫中進行的變更，包括：
+ 為什麼進行變更。
+ 是否需要更多變更。
+ 是否應將變更合併到另一個分支。

您可以對整體遞交、對遞交中的檔案或檔案內的特定行或變更進行評論。您也可以選取一行，然後在瀏覽器中複製產生的 URL，以連結至一行程式碼。

**注意**  
為了獲得最佳結果，請在以 IAM 使用者身分登入時使用註解。未針對使用根帳戶登入資料、聯合存取或臨時登入資料登入的使用者最佳化評論功能。

**Topics**
+ [檢視對儲存庫中遞交的評論](#how-to-commit-comment-view-console)
+ [新增和回覆對儲存庫中遞交的評論](#how-to-commit-comment-add-console)
+ [檢視、新增、更新和回覆評論 (AWS CLI)](#how-to-commit-comment-cli)

## 檢視對儲存庫中遞交的評論
<a name="how-to-commit-comment-view-console"></a>

您可以使用 CodeCommit 主控台來檢視遞交的評論。

**檢視對遞交的評論**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要檢閱對遞交評論的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**。選擇您想要檢視任何評論的遞交之遞交 ID。

   隨即會顯示該遞交的頁面，以及任何評論。

## 新增和回覆對儲存庫中遞交的評論
<a name="how-to-commit-comment-add-console"></a>

您可以使用 CodeCommit 主控台，將註解新增至遞交與父項的比較，或新增至兩個指定遞交之間的比較。您也可以使用表情符號、您自己的註解或兩者來回覆註解。

### 新增並回覆對遞交的評論 （主控台）
<a name="how-to-commit-comment-add-cpage"></a>

您可以使用文字和表情符號，將評論新增和回覆至遞交。您的註解和表情符號會標示為屬於您用來登入主控台的 IAM 使用者或角色。

**新增和回覆對遞交的評論**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要對遞交評論所在的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**。選擇您想要新增或回覆評論所在的遞交之遞交 ID。

   隨即會顯示該遞交的頁面，以及任何評論。

1. 若要新增評論，請執行以下其中一項：
   + 若要新增一般評論，請在 ​**Comments on changes (對變更加上評論)** 中，輸入評論，然後選擇 **Save (儲存)**。您可以使用 [Markdown](https://en.wikipedia.org/wiki/Markdown)，或也可以純文字輸入您的評論。  
![\[對遞交中變更的一般評論。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-changecomment.png)
   + 若要對遞交中的檔案新增評論，請找到檔案的名稱。選擇 **Comment on file (對檔案加上評論)**，輸入您的評論，然後選擇 **Save (儲存)**。  
![\[對遞交中的檔案新增評論。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-addfilecomment.png)
   + 若要對遞交中變更的一行新增評論，請前往變更出現的行。選擇評論氣泡![\[The comment bubble icon that that indicates that you can leave a comment on that line of code.\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commentbubble.png)，輸入您的評論，然後選擇 **Save (儲存)**。  
![\[對遞交中的一行新增評論。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-addlinecomment.png)
**注意**  
在儲存評論之後，您可以編輯評論，也可以刪除其內容。該評論將保留一則訊息，指出內容已遭刪除。考慮為您的評論使用 **Preview markdown (預覽 Markdown)** 模式，之後再進行儲存。

1. 若要回覆對遞交的評論，請選擇 **Reply (回覆)**。若要使用表情符號回覆評論，請從清單中選擇您想要的表情符號。每個註解只能選擇一個表情符號。如果您想要變更表情符號反應，請選擇與清單不同的表情符號反應，或選擇**無**以移除您的反應。  
![\[將回應和表情符號反應新增至註解。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commenting-commenttab.png)

### 在比較兩個遞交指標時新增和回覆註解
<a name="how-to-commit-comment-console-compare"></a>

您可以對分支、標籤或遞交之間的比較新增評論。

**比較遞交指標時新增和回覆評論**

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要比較遞交、分支或附加標籤之遞交所在的儲存庫。

1. 在導覽窗格中，選擇 **Commits (遞交)**，然後選擇 **Compare commits (比較遞交)** 索引標籤。  
![\[比較任兩個遞交指標\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-compare-1.png)

1. 使用 **Destination (目的地)** 和 **Source (來源)** 欄位來比較兩個遞交指標。使用下拉式清單或貼上遞交 ID。選擇 **Compare (比較)**。  
![\[將遞交 ID 與分支比較的範例結果\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-compare-4.png)

1. 執行下列其中一項或多項：
   + 若要將新增評論到檔案或行，請選擇評論氣泡 ![\[The comment bubble icon that that indicates that you can leave a comment on that line of code.\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-commentbubble.png)。
   + 若要對比較的變更新增一般評論，請移至 **Comments on changes (對變更的評論)**。

## 檢視、新增、更新和回覆評論 (AWS CLI)
<a name="how-to-commit-comment-cli"></a>

您可以透過執行下列命令來檢視、新增、回覆、更新和刪除評論的內容：
+ 若要檢視兩個遞交間比較的評論，請執行 **[get-comments-for-compared-commit](#how-to-commit-comment-cli-get-comments)**。
+ 若要檢視評論的詳細資訊，請執行 [**get-comment**](#how-to-commit-comment-cli-get-comment-info)。
+ 若要刪除您建立的評論內容，請執行 [**delete-comment-content**](#how-to-commit-comment-cli-commit-delete)。
+ 若要對兩個遞交間的比較建立評論，請執行 [**post-comment-for-compared-commit**](#how-to-commit-comment-cli-comment)。
+ 若要更新評論，請執行 [**update-comment**](#how-to-commit-comment-cli-commit-update)。
+ 若要回覆註解，請執行 [**post-comment-reply**](#how-to-commit-comment-cli-commit-reply)。
+ 若要使用表情符號回覆註解，請執行 [**put-comment-reaction**](#how-to-commit-comment-cli-commit-reply-emoji)。
+ 若要檢視註解的表情符號反應，請執行 [**get-comment-reactions**](#how-to-commit-comment-cli-commit-emoji-view)。

### 檢視對遞交的評論
<a name="how-to-commit-comment-cli-get-comments"></a>

1. 執行 **get-comments-for-compared-commit** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + 之後遞交的完整遞交 ID，以建立比較的方向性 (使用 `--after-commit-id option`)。
   + 之前遞交的完整遞交 ID，以建立比較的方向性 (使用 `--before-commit-id` 選項)。
   + (選用) 用來傳回下一個批次結果的列舉符記 (使用 `--next-token` 選項)。
   + (選用) 一個非負整數，用來限制傳回的結果 (使用 `--max-results` 選項)。

   例如，若要在名為 *MyDemoRepo* 的儲存庫中檢視兩個遞交之間的比較的註解：

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

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   {
      "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"
   }
   ```

### 檢視對遞交評論的詳細資訊
<a name="how-to-commit-comment-cli-get-comment-info"></a>

1. 執行 **get-comment** 命令，指定系統產生的評論 ID。例如：

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

1. 如果此命令成功執行，您會看到類似如下的輸出傳回：

   ```
   {
      "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
            }
      }
   }
   ```

### 刪除對遞交評論的內容
<a name="how-to-commit-comment-cli-commit-delete"></a>

1. 執行 **delete-comment-content** 命令，指定系統產生的評論 ID。例如：

   ```
   aws codecommit delete-comment-content --comment-id ff30b348EXAMPLEb9aa670f
   ```
**注意**  
只有在套用 AWSCodeCommitFullAccess 政策，或將`DeleteCommentContent`許可設定為**允許**時，才能刪除評論的內容。

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   {
      "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
            }
      }
   }
   ```

### 建立對遞交的評論
<a name="how-to-commit-comment-cli-comment"></a>

1. 執行 **post-comment-for-compared-commit** 命令，並指定：
   + CodeCommit 儲存庫的名稱 （使用 `--repository-name`選項）。
   + 之後遞交的完整遞交 ID，以建立比較的方向性 (使用 `--after-commit-id ` 選項)。
   + 之前遞交的完整遞交 ID，以建立比較的方向性 (使用 `--before-commit-id` 選項)。
   + 唯一的用戶端產生冪等符記 (使用 **--client-request-token** 選項)。
   + 評論的內容 (使用 **--content** 選項)。
   + 可放置評論位置的清單位置相關資訊，包括：
     + 要比較的檔案名稱，包括其副檔名和子目錄 (如果有) (使用 **filePath** 屬性)。
     + 比較檔案內變更的行號 (使用 **filePosition** 屬性)。
     + 對變更的評論在來源與目的地分支之間的比較中為之前或之後 (使用 **relativeFileVersion** 屬性)。

   例如，若要新增註解*「您可以為此新增測試案例嗎？」* 在名為 *MyDemoRepo* 的儲存庫中兩個遞交之間的比較中，*cl\$1sample.js* 檔案的變更：

   ```
   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. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   { 
            "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"
    }
   ```

### 更新對遞交的評論
<a name="how-to-commit-comment-cli-commit-update"></a>

1. 執行 **update-comment** 命令，指定系統產生的評論 ID 和您要用來取代任何現有內容的內容。

   例如，若要新增內容 *"Fixed as requested. 我將更新提取請求。」* 至 ID 為 *442b498bEXAMPLE5756813* 的註解：

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

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   { 
       "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
             }
       }
    }
   ```

### 回覆對遞交的評論
<a name="how-to-commit-comment-cli-commit-reply"></a>

1. 若要對提取請求中的評論張貼回覆，請執行 **post-comment-reply** 命令，指定：
   + 您要回覆的評論由系統產生的 ID (使用 **--in-reply-to** 選項)。
   + 唯一的用戶端產生冪等符記 (使用 **--client-request-token** 選項)。
   + 回覆的內容 (使用 **--content** 選項)。

    例如，若要新增「*良好捕獲」回覆。我將移除它們。」* 至系統產生的 ID 為 *abcd1234EXAMPLEb5678efgh* 的註解：

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

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   { 
       "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": []
       }
    }
   ```

### 使用表情符號回覆對遞交的評論
<a name="how-to-commit-comment-cli-commit-reply-emoji"></a>

1. 若要使用表情符號回覆提取請求中的註解，或變更表情符號反應的值，請執行 **put-comment-reaction**命令，指定：
   + 您要以表情符號回覆之註解的系統產生 ID。
   + 您要新增或更新的反應值。可接受的值包括支援的表情符號、短碼和 Unicode 值。<a name="emoji-reaction-table"></a>

   CodeCommit 中的表情符號支援下列值：  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/how-to-commit-comment.html)

    例如，若要將表情符號 *：thumbsup：* 新增至系統產生的 ID 為 *abcd1234EXAMPLEb5678efgh* 的註解：

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

1. 如果成功，此命令就不會產生輸出。

### 檢視對註解的表情符號反應
<a name="how-to-commit-comment-cli-commit-emoji-view"></a>

1. 若要檢視對註解的表情符號反應，包括與這些表情符號做出反應的使用者，請執行 **get-comment-reactions**命令，指定系統產生的註解 ID。

    例如，若要檢視系統產生 ID 為 *abcd1234EXAMPLEb5678efgh* 之註解的表情符號反應：

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

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   {
       "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"
                   ]
               }
           ]
       }
   }
   ```

# 在 中建立 Git 標籤 AWS CodeCommit
<a name="how-to-create-tag"></a>

您可以使用 Git 標籤來標記遞交，以協助其他儲存庫使用者了解其重要性。若要在 CodeCommit 儲存庫中建立 Git 標籤，您可以從連線至 CodeCommit 儲存庫的本機儲存庫使用 Git。在本機儲存庫中建立 Git 標籤後，您可以使用 將其**git push --tags**推送至 CodeCommit 儲存庫。

如需詳細資訊，請參閱[檢視標籤詳細資訊](how-to-view-tag-details.md)。

## 使用 Git 建立標籤
<a name="how-to-create-tag-git"></a>

請依照下列步驟，從本機儲存庫使用 Git，在 CodeCommit 儲存庫中建立 Git 標籤。

在這些步驟中，我們假設您已將本機儲存庫連線至 CodeCommit 儲存庫。如需說明，請參閱[連接到儲存庫](how-to-connect.md)。

1. 執行 **git tag *new-tag-name* *commit-id*** 命令，其中 *new-tag-name* 是新的 Git 標籤名稱，以及 *commit-id* 是要與 Git 標籤關聯的遞交的 ID。

   例如，以下命令會建立名為 `beta` 的 Git 標籤，並將它與遞交 ID `dc082f9a...af873b88` 建立關聯：

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

1. 若要將新的 Git 標籤從本機儲存庫推送到 CodeCommit 儲存庫，請執行 **git push *remote-name* *new-tag-name***命令，其中 *remote-name* 是 CodeCommit 儲存庫的名稱，而 *new-tag-name* 是新的 Git 標籤的名稱。

   例如，若要將名為 的新 Git 標籤推送`beta`至名為 的 CodeCommit 儲存庫`origin`：

   ```
   git push origin beta
   ```

**注意**  
若要將所有新的 Git 標籤從本機儲存庫推送到 CodeCommit 儲存庫，請執行 **git push --tags**。  
若要確保本機儲存庫已更新 CodeCommit 儲存庫中的所有 Git 標籤，請執行 ，**git fetch**後面接著 **git fetch --tags**。

如需更多選項，請參閱 Git 文件。

# 在 中檢視 Git 標籤詳細資訊 AWS CodeCommit
<a name="how-to-view-tag-details"></a>

在 Git 中，標籤是一個標記，可套用到參考 (例如遞交)，以將它標示為對其他儲存庫使用者可能重要的資訊。例如，您可以使用標籤 **beta** 來標記屬於專案 Beta 版發行點的遞交。如需詳細資訊，請參閱[使用 Git 建立標籤](how-to-create-tag.md#how-to-create-tag-git)。Git 標籤與儲存庫標籤不同。如需有關如何使用儲存庫標籤的詳細資訊，請參閱 [新增標籤至儲存庫](how-to-tag-repository-add.md)。

您可以使用 AWS CodeCommit 主控台來檢視儲存庫中 Git 標籤的相關資訊，包括每個 Git 標籤所參考遞交的日期和遞交訊息。從主控台，您可以使用儲存庫的預設分支標頭來比較標籤參考的遞交。如同任何其他遞交，您也可以檢視該 Git 標籤時間點的程式碼。

您也可以從終端機或命令列使用 Git，以檢視本機儲存庫中 Git 標籤的詳細資訊。

**Topics**
+ [檢視標籤詳細資訊 （主控台）](#how-to-view-tag-details-console)
+ [檢視 Git 標籤詳細資訊 (Git)](#how-to-view-tag-details-git)

## 檢視標籤詳細資訊 （主控台）
<a name="how-to-view-tag-details-console"></a>

使用 AWS CodeCommit 主控台快速檢視儲存庫的 Git 標籤清單，以及 Git 標籤所參考遞交的詳細資訊。

1. 在 https：//[https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home) 開啟 CodeCommit 主控台。

1. 在 **Repositories (儲存庫)** 中，選擇您要檢視標籤所在的儲存庫名稱。

1. 在導覽窗格中，選擇 **Git tags (Git 標籤)**。  
![\[儲存庫中的標籤檢視。\]](http://docs.aws.amazon.com/zh_tw/codecommit/latest/userguide/images/codecommit-tags-view.png)

1. 執行以下任意一項：
   + 若要檢視程式碼在遞交時的狀態，請選擇 Git 標籤名稱。
   + 若要檢視遞交的詳細資訊 (包括完整的遞交訊息、遞交者和作者)，請選擇縮寫的遞交 ID。

## 檢視 Git 標籤詳細資訊 (Git)
<a name="how-to-view-tag-details-git"></a>

若要使用 Git 檢視本機儲存庫中 Git 標籤的詳細資訊，請執行下列其中一個命令：
+ [git tag](#how-to-view-tag-details-git-tag) 可檢視 Git 標籤名稱的清單。
+ [git show](#how-to-view-tag-details-git-show) 可檢視特定 Git 標籤的詳細資訊。
+ [git ls-remote](#how-to-view-tag-details-git-remote) 以檢視 CodeCommit 儲存庫中 Git 標籤的相關資訊。

**注意**  
為了確保您的本機儲存庫已更新 CodeCommit 儲存庫中的所有 Git 標籤，請執行 ，**git fetch**後面接著 **git fetch --tags**。

在下列步驟中，我們假設您已將本機儲存庫連線至 CodeCommit 儲存庫。如需說明，請參閱[連接到儲存庫](how-to-connect.md)。

### 檢視本機儲存庫中的 Git 標籤清單
<a name="how-to-view-tag-details-git-tag"></a>

1. 執行 **git tag** 命令：

   ```
   git tag
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   beta
   release
   ```
**注意**  
如果沒有定義任何標籤，**git tag** 不會傳回任何內容。

如需更多選項，請參閱 Git 文件。

### 檢視本機儲存庫中 Git 標籤的相關資訊
<a name="how-to-view-tag-details-git-show"></a>

1. 執行 **git show *tag-name*** 命令。例如，若要檢視名為 `beta` Git 標籤的詳細資訊，請執行：

   ```
   git show beta
   ```

1. 如果此命令成功執行，您會看到類似如下的輸出產生：

   ```
   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
   ```
**注意**  
若要結束 Git 標籤資訊的輸出，請輸入 **:q**。

如需更多選項，請參閱 Git 文件。

### 檢視 CodeCommit 儲存庫中 Git 標籤的相關資訊
<a name="how-to-view-tag-details-git-remote"></a>

1. 執行 **git ls-remote --tags** 命令。

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

1. 如果成功，此命令會產生輸出 CodeCommit 儲存庫中的 Git 標籤清單：

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

   如果沒有定義任何 Git 標籤，**git ls-remote --tags** 會傳回空白的行。

如需更多選項，請參閱 Git 文件。

# 在 中刪除 Git 標籤 AWS CodeCommit
<a name="how-to-delete-tag"></a>

若要刪除 CodeCommit 儲存庫中的 Git 標籤，請從連線至 CodeCommit 儲存庫的本機儲存庫使用 Git。

## 使用 Git 刪除 Git 標籤
<a name="how-to-delete-tag-git"></a>

請依照下列步驟，從本機儲存庫使用 Git 刪除 CodeCommit 儲存庫中的 Git 標籤。

這些步驟的撰寫假設您已將本機儲存庫連線至 CodeCommit 儲存庫。如需說明，請參閱[連接到儲存庫](how-to-connect.md)。

1. 若要從本機儲存庫刪除 Git 標籤，請執行 **git tag -d *tag-name***命令，其中 *tag-name* 是您想要刪除的 Git 標籤名稱。
**提示**  
若要取得 Git 標籤名稱的清單，請執行 **git tag**。

   例如，若要在名為 的本機儲存庫中刪除 Git 標籤`beta`：

   ```
   git tag -d beta
   ```

1. 若要從 CodeCommit 儲存庫刪除 Git 標籤，請執行 **git push *remote-name* --delete *tag-name***命令，其中 *remote-name* 是本機儲存庫用於 CodeCommit 儲存庫的別名，而 *tag-name* 是您要從 CodeCommit 儲存庫刪除的 Git 標籤名稱。
**提示**  
若要取得 CodeCommit 儲存庫名稱及其 URLs的清單，請執行 **git remote -v**命令。

   例如，若要在名為 的 CodeCommit 儲存庫`beta`中刪除名為 的 Git 標籤`origin`： CodeCommit 

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