b. Create a repo in CodeCommit

  1. Confirm you are in the MyDemoRepo directory:
cd ~/environment/MyDemoRepo
  1. Make this directory into a Git repository, and add an initial commit containing the files we created in the previous step.
git init # initializes the git repository in this directory
git branch -m main # name the default brainch 'main'
git add Dockerfile spack.yaml # stage our files for commit
git commit -m "Created Dockerfile and spack files" # create a point-in-time commit

You can safely ingore git warnings about user.name and user.email not being set.

Next, you will use the AWS Command Line Interface (CLI) to create a Git repository in AWS CodeCommit where we can push our local git repository.

  1. Next create your CodeCommit Repo:

AWS CodeCommit is a secure, highly scalable, managed source control service that hosts private Git repositories.

aws codecommit create-repository --repository-name MyDemoRepo --repository-description "My demonstration repository" --tags Team=SC22
  1. Get repository URL:
REPOURL=$(aws codecommit get-repository --repository-name MyDemoRepo --query repositoryMetadata.cloneUrlHttp --output text ) 
echo $REPOURL

Verify echo $REPOURL outputs a repo url like https://git-codecommit.<region>.amazonaws.com/v1/repos/MyDemoRepo

  1. Add the CodeCommit as the origin remote for our git repository:
git remote add origin $REPOURL

Verify that the git remote is set correctly:

git remote -v

You should get output:

origin	https://git-codecommit.<region>.amazonaws.com/v1/repos/MyDemoRepo (fetch)
origin	https://git-codecommit.<region>.amazonaws.com/v1/repos/MyDemoRepo (push)
  1. Push the local Git changes to CodeCommit:
git push -u origin main

Verify that the CodeCommit and local repositories are synchronized with:

git fetch && git status

You should get output like:

...
On branch main
Your branch is up to date with 'origin/main'.
...