AWS Code Commit
AWS CodeCommit - 基礎用法
AWS CodeCommit 是完全託管的原始碼控制服務,可託管安全的 Git 儲存庫,相當於一個Private GitHub。它可讓團隊在安全且高度可擴充套件的生態系統中輕鬆協作處理程式碼。使用 CodeCommit,無需執行自己的原始碼控制系統,也無需擔心基礎設施的擴充套件能力。可以使用 CodeCommit 將來自原始碼的任何資料安全儲存為二進位制檔案,而且它可以無縫相容您現有的 Git 工具。
下面,我們一起探索一下CodeCommit的基本用法,來實現你的第一個Commit。
1. Create an AWS CodeCommit Repository
Create in the AWS Console:
Service Menu -> CodeCommit -> Create repository
On the Create repository page, configure:
- Name: My-Repo
- Description: My first repository
- Click Create
An empty repo called My-Repo will be created in CodeCommit. Connection details will be shown.
2. Create an EC2 Instance
Create an EC2 instance in the AWS Console, and record down the public IP address.
3. Connect the CodeCommit to the EC2 instance
通常有兩種方式:
- SSH keys for AWS CodeCommit
- HTTPS Git credentials for AWS CodeCommit
這裡,我們使用 SSH keys for AWS CodeCommit
Before this step, you need to create a Key pair for authentication. Say the name is “KEYPAIR.pem”.
Save the .pem file to your local computer.
- chmod command: change the access permissions of file system objects
- ssh command: can ssh to the EC2 public IP
chmod 400 KEYPAIR.pem
ssh -i KEYPAIR.pem ec2-user@EC2PublicIP
chmod 400 qwikLABS-L2990-19969242.pem
ssh -i qwikLABS-L2990-19969242.pem ec2-user@3.230.119.106
- Type yes when prompted to allow a first connection to this remote SSH server.
- Because you are using a key pair for authentication, you will not be prompted for a password.
4. In the EC2, create a Local Repo using Git
- Install the git client:
sudo yum install -y git
- Use the Git credentials helper with the AWS credentials profile, and enables the Git credentials helper to send the path to repositories.
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
- You will now need to obtain the HTTPS URL of your AWS CodeCommit repository.
- In the AWS CodeCommit Management Console, click the Clone URL then click Clone HTTPS
- The URL look similar to below:
https://git-codecommit.us-east-1.amazonaws.com/v1/repos/My-Repo - In the remote SSH session, copy and paste: git clone URL(Replace the URL with the CodeCommit clone URL), and run the command
- You should see the following message:
Cloning in to ‘my-demo-repo’…
Warning: You appear to have cloned an empty repository.
5. Make a Code Change in the EC2, and Commit to the Repo
To create your first commit in your local repo.
- Use the following command to create two files with content in your local repo:
cd ~/My-Repo
echo "The domestic cat (Felis catus or Felis silvestris catus) is a small, usually furry, domesticated, and carnivorous mammal." >cat.txt
echo "The domestic dog (Canis lupus familiaris) is a canid that is known as man's best friend." >dog.txt
- List the directory to see the files were created
ls
- Run this command to stage the change in your local repo:
git add cat.txt dog.txt
- View the status of your repo:
git status
You will see the two files are ready to be committed to the repo.
- Run the command to commit the change in your local repo:
git commit -m "Added cat.txt and dog.txt"
- View the details about the commit you just made:
git log
6. Push your first Commit
- Push the commit from your local repo to your AWS CodeCommit Repository.
git push -u origin master
Once you pushed code to the AWS CodeComit repo, you can view the contents using the AWS CodeCommit console.
- In the CodeCommit Management Console, ensure you are in the My-Repo repo.
- Refresh your screen. The two files that you added to your repo should be displayed.
- Click each file to view the contents.
Congratulations! You have created an AWS CodeCommit repo and can now consider how to bring its features and capabilities to your development workflow. These include:
- Collaboration
- Encryption
- Access Control
- High Availability and Durability
- Unlimited Repositories
- Easy Access and Integration
相關文章
- 如何從 AWS CodeCommit 遷移到極狐GitLab?MITGitlab
- AWS CodePipeline部署Maven專案至EC2Maven
- AWS Switching to an IAM role (AWS CLI)
- AWS 高可用AWS架構方案架構
- git commit後如何取消commitGitMIT
- on commit delete rows and on commit preserve rowsMITdelete
- Vscode中新功能Commit Graph能提升Git提交效能VSCodeMITGit
- CommitMIT
- eclipse svn commit 報錯 Commit blocked by pre-commit hookEclipseMITBloCHook
- [原創] How to pull code when shared repo commit history has been changedMIT
- Git commit 之後,想撤銷 commitGitMIT
- svn commitMIT
- Asynchronous CommitMIT
- AWS學習
- Container on AWSAI
- commit 與do_key('commit_form')區別MITORM
- git commit --amendGitMIT
- commit 衝突MIT
- commit_writeMIT
- AWS可以自動部署程式碼的codedeply,更新程式就這麼簡單
- AWS 使用經驗
- Udemy AWS SAA - RDS
- AWS雲服務
- git commit 彈出編輯器後報錯: Aborting commit due to empty commit message.GitMIT
- commit_write,commit_logging,commit_wait引數和oracle redo行為MITAIOracle Redo
- 關於Git commitGitMIT
- Git拆分commit提交GitMIT
- 修改 commit messageMIT
- 增強的 COMMITMIT
- oracle之commit控制OracleMIT
- commit做了什麼?MIT
- 關於oracle commitOracleMIT
- 物化檢視 on commitMIT
- Commit Transactions (143)MIT
- Git commit規範GitMIT
- git 修改 commit 資訊GitMIT
- git commit 規範GitMIT
- 【Oracle】-【隱式commit】-正常與異常退出對commit的作用OracleMIT