Learning Objective:
Learn how to create a CodeCommit repository and clone it to your AWS CloudShell
Learn how to stage and commit a file to your cloned repository.
Prerequisites
A basic understanding of Git commands and version control concepts
A file in the home directory of your shell that can be committed to the local and remote repositories. In this tutorial, it's referred to as my-git-file.
Step 1:
In the top right corner of AWS console click on CloudShell icon.
This window will show up. Here we are using Europe (Ireland)eu-west-1
Step 2:
Create and clone a CodeCommit repository.
1. In the CloudShell command line interface, enter the following codecommit command to create a CodeCommit repository called MyDemoRepo
aws codecommit create-repository --repository-name MyDemoRepo --repository-description "My demonstration repository"
2. Using the CloudShell command line interface, create a new directory for your local repository and make it your working directory.
mkdir my-shell-repo
cd my-shell-repo
3. To clone the remote repository, use the git clone command. (As you're working with git-remote-codecommit, use the HTTPS (GRC) URL style).
git clone codecommit::eu-west-1://MyDemoRepo
If the repository is successfully cloned, the command line displays the service's response.
4. To navigate to the cloned repository, use the cd command.
cd MyDemoRepo
Step 3:
Stage and commit a file before pushing it to your CodeCommit repository.
1. Add a file called my-git-file to the MyDemoRepo folder using either a Vim editor or the file upload feature of AWS CloudShell.
vim my-git-file
with this you will enter in vim editor once you do press Escape and you will enter in command mod. Now type :wq
Once you enter it will take you back to the CloudShell.
2. To stage your file in the repository, run the git add command.
git add my-git-file
3. To check that the file has been staged and is ready to be committed, run the git status command.
git status
my-git-file is listed as a new file and displays in green text, indicating it's ready to be committed.
Note:
If you're asked for configuration information to complete the commit, use the following format.
git config --global user.name "Jane Doe"
git config --global user.email janedoe@example.com
4. Commit this version of the staged file to the repository.
git commit -m "first commit to repo"
5. To sync your remote repository with the changes made in your local one, push the changes to the upstream branch.
git push
Note: If you no longer need this CloudShell environment delete it.
Was this document helpful? How can we make this document better. Please provide your insights. You can download PDF version for reference.
For your aws certification needs or for aws learning contact us.
well defined
Easy to understand
Easy to follow
Very useful sir
Useful