Copy and paste the following lines at the end of the sam-app/.gitgnore file. There is no need to track the .aws-sam directory or the packaged.yaml under version control as they are re-generated on every build.
.aws-sam/
packaged.yaml
In Cloud9, remember to enable hidden files:

Open the .gitignore file and paste the two lines described above.

From the root directory of your sam-app project, run the following commands:
cd ~/environment/sam-app
git init
git add .
git commit -m "Initial commit"
Example:

Add your CodeCommit repository URL as a remote on your local git project. This is the cloneUrlHttp value that you got back after creating the repository in Step 1 of this chapter.
If you can’t find the CodeCommit repository URL, you can find it by running this command: aws codecommit get-repository --repository-name sam-app.
git remote add origin REPLACE_WITH_HTTP_CLONE_URL
If you typed the origin url incorrectly, you can remove it by running: git remote rm origin.
Now, push the code:
git push -u origin master
Example:

Navigate to the AWS CodeCommit console, find your sam-app repository and click on it to view its contents. Make sure your code is there. You should see a screen like the following:
