Git Config

The git config command is a convenience function that is used to set Git configuration values on a global or local project level. It is best practice to set up your git user.name and user.email when you set up a new Cloud9 environment using the following commands:

git config --global user.name "Full Name"
git config --global user.email email@amazon.com

Configure the AWS CLI Credential Helper on Your AWS Cloud9 EC2 Development Environment

After you’ve created an AWS Cloud9 environment, you can configure the AWS CLI credential helper to manage the credentials for connections to your CodeCommit repository. The AWS Cloud9 development environment comes with AWS managed temporary credentials that are associated with your IAM user. You use these credentials with the AWS CLI credential helper. The credential helper allows Git to use HTTPS and a cryptographically signed version of your IAM user credentials or Amazon EC2 instance role whenever Git needs to authenticate with AWS to interact with CodeCommit repositories.

At the terminal, run the following commands to configure the AWS CLI credential helper for HTTPS connections:

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

Install gitflow

gitflow is a collection of Git extensions to provide high-level repository operations for Vincent Driessen’s branching model. At the terminal, run the following commands to install gitflow:

curl -OL https://raw.github.com/nvie/gitflow/develop/contrib/gitflow-installer.sh
chmod +x gitflow-installer.sh
sudo ./gitflow-installer.sh

Get a copy of the sample code

In this step, you will retrieve a copy of the sample app’s code and create code commit repo to host the code. The pipeline takes code from the source and then performs actions on it.

Stage 1: Create Code Commit Repo

aws codecommit create-repository --repository-name gitflow-workshop --repository-description "Repository for Gitflow Workshop"
git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/gitflow-workshop

The remaining steps in this tutorial assume you have named your AWS CodeCommit repository gitflow-workshop. If you use a name other than gitflow-workshop, be sure to use it throughout this tutorial.

codecommit

You can check if the repository was created here

Stage 2: Download the sample code and commit your code to the repository

  1. Download the Sample App archive by running the following command from IDE terminal.

    wget https://aws-workshop-gitflow.s3.amazonaws.com/gitflow.zip
  2. Unarchive and copy all the contents of the unarchived folder to your local repo folder.

    unzip gitflow.zip -d gitflow-workshop/
  3. Change the directory to your local repo folder. Run git add to stage the change.

    cd gitflow-workshop
    git add -A
  4. Run git commit to commit the change and push it to master

    git commit -m "Initial Commit"
    git push origin master

And you should see something similar to:

Counting objects: 17, done.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 49.62 KiB | 4.96 MiB/s, done.
Total 17 (delta 1), reused 0 (delta 0)
To https://git-codecommit.us-east-1.amazonaws.com/v1/repos/gitflow-workshop
 * [new branch]      master -> master