

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh [SDK AWS Doc](https://github.com/awsdocs/aws-doc-sdk-examples). GitHub 

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# CodeCommit contoh menggunakan Alat untuk PowerShell V4
<a name="powershell_4_codecommit_code_examples"></a>

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan Alat AWS untuk PowerShell V4 dengan CodeCommit.

*Tindakan* merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

**Topics**
+ [Tindakan](#actions)

## Tindakan
<a name="actions"></a>

### `Get-CCBranch`
<a name="codecommit_GetBranch_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-CCBranch`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mendapat informasi tentang cabang yang ditentukan untuk repositori yang ditentukan.**  

```
Get-CCBranch -RepositoryName MyDemoRepo -BranchName MyNewBranch
```
**Output:**  

```
BranchName                              CommitId
----------                              --------
MyNewBranch                             7763222d...561fc9c9
```
+  Untuk detail API, lihat [GetBranch](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Get-CCBranchList`
<a name="codecommit_ListBranches_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-CCBranchList`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mendapatkan daftar nama cabang untuk repositori yang ditentukan.**  

```
Get-CCBranchList -RepositoryName MyDemoRepo
```
**Output:**  

```
master
MyNewBranch
```
+  Untuk detail API, lihat [ListBranches](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Get-CCRepository`
<a name="codecommit_GetRepository_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-CCRepository`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mendapatkan informasi untuk repositori yang ditentukan.**  

```
Get-CCRepository -RepositoryName MyDemoRepo
```
**Output:**  

```
AccountId             : 80398EXAMPLE
Arn                   : arn:aws:codecommit:us-east-1:80398EXAMPLE:MyDemoRepo
CloneUrlHttp          : https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo
CloneUrlSsh           : ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo
CreationDate          : 9/8/2015 3:21:33 PM
DefaultBranch         :
LastModifiedDate      : 9/8/2015 3:21:33 PM
RepositoryDescription : This is a repository for demonstration purposes.
RepositoryId          : c7d0d2b0-ce40-4303-b4c3-38529EXAMPLE
RepositoryName        : MyDemoRepo
```
+  Untuk detail API, lihat [GetRepository](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Get-CCRepositoryBatch`
<a name="codecommit_BatchGetRepositories_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-CCRepositoryBatch`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengonfirmasi repositori mana yang ditemukan dan tidak ditemukan.**  

```
Get-CCRepositoryBatch -RepositoryName MyDemoRepo, MyNewRepo, AMissingRepo
```
**Output:**  

```
Repositories                            RepositoriesNotFound
------------                            --------------------
{MyDemoRepo, MyNewRepo}                {AMissingRepo}
```
+  Untuk detail API, lihat [BatchGetRepositories](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Get-CCRepositoryList`
<a name="codecommit_ListRepositories_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-CCRepositoryList`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mencantumkan semua repositori dalam urutan menaik berdasarkan nama repositori.**  

```
Get-CCRepositoryList -Order Ascending -SortBy RepositoryName
```
**Output:**  

```
RepositoryId                            RepositoryName
------------                            --------------
c7d0d2b0-ce40-4303-b4c3-38529EXAMPLE    MyDemoRepo
05f30c66-e3e3-4f91-a0cd-1c84aEXAMPLE    MyNewRepo
```
+  Untuk detail API, lihat [ListRepositories](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `New-CCBranch`
<a name="codecommit_CreateBranch_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`New-CCBranch`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini membuat cabang baru dengan nama yang ditentukan untuk repositori tertentu dan ID komit yang ditentukan.**  

```
New-CCBranch -RepositoryName MyDemoRepo -BranchName MyNewBranch -CommitId 7763222d...561fc9c9
```
+  Untuk detail API, lihat [CreateBranch](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `New-CCRepository`
<a name="codecommit_CreateRepository_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`New-CCRepository`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini membuat repositori baru dengan nama yang ditentukan dan deskripsi yang ditentukan.**  

```
New-CCRepository -RepositoryName MyDemoRepo -RepositoryDescription "This is a repository for demonstration purposes."
```
**Output:**  

```
AccountId             : 80398EXAMPLE
Arn                   : arn:aws:codecommit:us-east-1:80398EXAMPLE:MyDemoRepo
CloneUrlHttp          : https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo
CloneUrlSsh           : ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo
CreationDate          : 9/18/2015 4:13:25 PM
DefaultBranch         :
LastModifiedDate      : 9/18/2015 4:13:25 PM
RepositoryDescription : This is a repository for demonstration purposes.
RepositoryId          : 43ef2443-3372-4b12-9e78-65c27EXAMPLE
RepositoryName        : MyDemoRepo
```
+  Untuk detail API, lihat [CreateRepository](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Remove-CCRepository`
<a name="codecommit_DeleteRepository_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Remove-CCRepository`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini secara paksa menghapus repositori yang ditentukan. Perintah akan meminta konfirmasi sebelum melanjutkan. Tambahkan parameter -Force untuk menghapus repositori tanpa prompt.**  

```
Remove-CCRepository -RepositoryName MyDemoRepo
```
**Output:**  

```
43ef2443-3372-4b12-9e78-65c27EXAMPLE
```
+  Untuk detail API, lihat [DeleteRepository](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Update-CCDefaultBranch`
<a name="codecommit_UpdateDefaultBranch_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Update-CCDefaultBranch`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengubah cabang default untuk repositori yang ditentukan ke cabang yang ditentukan.**  

```
Update-CCDefaultBranch -RepositoryName MyDemoRepo -DefaultBranchName MyNewBranch
```
+  Untuk detail API, lihat [UpdateDefaultBranch](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Update-CCRepositoryDescription`
<a name="codecommit_UpdateRepositoryDescription_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Update-CCRepositoryDescription`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengubah deskripsi untuk repositori yang ditentukan.**  

```
Update-CCRepositoryDescription -RepositoryName MyDemoRepo -RepositoryDescription "This is an updated description."
```
+  Untuk detail API, lihat [UpdateRepositoryDescription](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

### `Update-CCRepositoryName`
<a name="codecommit_UpdateRepositoryName_powershell_4_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Update-CCRepositoryName`.

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini mengubah nama repositori yang ditentukan.**  

```
Update-CCRepositoryName -NewName MyDemoRepo2 -OldName MyDemoRepo
```
+  Untuk detail API, lihat [UpdateRepositoryName](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 