CodeCommit 是什么雁歌? - AWS的介紹是這樣的:
CodeCommit 是一項安全的、可高度擴(kuò)展的托管型源代碼控制服務(wù)礼仗,可用于托管私有 Git 存儲庫祸憋。CodeCommit 使您無需管理自己的源代碼控制系統(tǒng)会宪,并且再也不必?fù)?dān)心基礎(chǔ)設(shè)施的擴(kuò)展了。您可以使用 CodeCommit 存儲從代碼到二進(jìn)制文件的一切內(nèi)容蚯窥。它支持 Git 的標(biāo)準(zhǔn)功能掸鹅,可與您現(xiàn)有的基于 Git 的工具無縫協(xié)作。
一句話概括拦赠,就是私有GIT庫巍沙,當(dāng)然通過設(shè)置可以共享給其他人。
1荷鼠、首先要在http://aws.amazon.com AWS上創(chuàng)建一個賬戶句携,然后在AWS賬戶里創(chuàng)建IAM用戶。
2允乐、登錄AWS管理控制臺矮嫉,然后打開IAM控制臺https://console.aws.amazon.com/iam/。
3牍疏、在IAM導(dǎo)航窗選擇Users蠢笋,選擇要配置進(jìn)行CodeCommit訪問的IAM用戶。
屏幕快照 2019-06-03 16.30.59.png
4鳞陨、在Permissions選項卡昨寞,選擇Add Permissions, 然后在Grant permissions中選擇 Attach existing policies directly。

4炊邦、本機(jī)安裝Git就不說了编矾,這個很容易熟史。
5馁害、為訪問CodeCommit 安裝Git憑證
同樣,在IAM用戶界面蹂匹,點擊Security credentials頁碘菜,可以選擇Create access Key, 或則Upload SSH public key,或者生成HTTPS憑證(HTTPS Git credentials for AWS CodeCommit)。這里建議直接上載SSH public key
6忍啸、這里介紹使用MAC和Linux連接仰坦,Windows的參考:Windows 上的 SSH 連接
6.1、生成ssh key : ssh-key -t rsa
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user-name/.ssh/id_rsa): Type /home/your-user-name/.ssh/ and a file name here, for example /home/your-user-name/.ssh/codecommit_rsa
Enter passphrase (empty for no passphrase): <Type a passphrase, and then press Enter>
Enter same passphrase again: <Type the passphrase again, and then press Enter>
Your identification has been saved in /home/user-name/.ssh/codecommit_rsa.
Your public key has been saved in /home/user-name/.ssh/codecommit_rsa.pub.
The key fingerprint is:
45:63:d5:99:0e:99:73:50:5e:d4:b3:2d:86:4a:2c:14 user-name@client-name
The key's randomart image is:
+--[ RSA 2048]----+
| E.+.o*.++|
| .o .=.=o.|
| . .. *. +|
| ..o . +..|
| So . . . |
| . |
| |
| |
| |
起名codecommit计雌,在~/.ssh/目錄下生成codecommit_rsa和codecommit_rsa.pub文件
6.2 拷貝公鑰 cat ~/.ssh/codecommit_rsa.pub
回到IAM控制臺悄晃,點擊Upload SSH public key, 粘貼拷貝的公鑰內(nèi)容,然后能夠看到一個SSH key ID.
6.3 回到本機(jī)凿滤,在~/.ssh/目錄下生成叫做config的文件妈橄,內(nèi)容如下:
Host git-codecommit.*.amazonaws.com
User APKAEIBAERJR2EXAMPLE
IdentityFile ~/.ssh/codecommit_rsa
這里的User就是剛才在AWS記錄下來的SSH key ID.
6.4 更改配置文件屬性:
chmod 600 config
7、使用CodeCommit
回到AWS CodeCommit控制臺翁脆,找到你創(chuàng)建的Repositories, 點擊 Clone URL, 會拷貝git庫的鏈接眷蚓,或者由管理員發(fā)給你鏈接:
屏幕快照 2019-06-03 16.54.57.png
然后回到本機(jī),git clone XXXXXXXX反番,剩下的就跟通常使用git一樣沒啥區(qū)別了沙热。