

# Module 1: Set Up Git Repo
<a name="module-one"></a>


|  |  | 
| --- |--- |
|  **Time to complete**  |  5 minutes   | 
|  **Requires**  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/hands-on/latest/create-continuous-delivery-pipeline/module-one.html)  | 

## Overview
<a name="overview"></a>

In this module, you will set up a repository for your code so it can be easily accessed over the Internet. In this example, we will be using [GitHub](https://github.com/), but there are other Git-compatible options you can use, including [AWS CodeCommit](https://aws.amazon.com/codecommit/). In one of the following modules you will connect this hosted repo to our pipeline, so every time you push a new commit to it your build process is started. 

## What you will accomplish
<a name="what-you-will-accomplish"></a>
+ Fork a GitHub repository to create a new one 
+ Store code and metadata in GitHub 
+ Interact with a code repository using Git 

## Key concepts
<a name="key-concepts"></a>

**Version control—**A system for storing source code and tracking any changes to it. Changes are stored as versions, so a developer can easily compare versions or choose to revert to an older version. 

**Git—**An [open-source version control tool](https://git-scm.com/) for managing changes to source code. 

**Git repository (repo)—**All the files and directories that will be tracked by the version control system, including metadata. Each user will interact with a complete copy locally and push files to the hosted version to share changes. 

**Git commit—**The method to add changes to a Git repository. 

**Pushing to a repository—**Copying any changes stored via a commit from a local repository to a hosted one. 

**Forking a repository—**Creating a copy of an existing repository. 

## Implementation
<a name="implementation"></a>

### Step 1: Fork the starter repo
<a name="fork-the-starter-repo"></a>

This tutorial assumes you have an existing GitHub account and Git installed on your computer. If you don't have either of these two installed, you can follow these [step-by-step instructions](https://docs.github.com/en/github/getting-started-with-github/quickstart). 

1. Sign in to GitHub

   In a new browser tab, navigate to [GitHub](https://github.com/) and make sure you are logged into your account. 

1. Open the repo

   In that same tab, open the [aws-elastic-beanstalk-express-js-sample](https://github.com/aws-samples/aws-elastic-beanstalk-express-js-sample) repo. 

1. Fork the repo

   Choose the white** Fork** button on the top right corner of the screen. Next, you will see a small window asking you where you would like to fork the repo. 

1. Create the fork

   Verify it is showing your account and choose **Create a fork**. After a few seconds, your browser will display a copy of the repo in your account under **Repositories**. 

### Step 2: Push a change to your new repo
<a name="push-a-change-to-your-new-repo"></a>

1. Copy the repo URL

   Go to the [repository](https://github.com/aws-samples/aws-elastic-beanstalk-express-js-sample) and choose the green **Code** button near the top of the page. 

   To clone the repository using HTTPS, confirm that the heading says **Clone with HTTPS.** If not, select the **Use HTTPS** link. 

   Choose the white button with a clipboard icon on it (to the right of the URL).   
![\[The GitHub 'Code' dropdown showing clone options for HTTPS, SSH, and GitHub CLI, along with URLs, used in the AWS create continuous delivery pipeline tutorial.\]](http://docs.aws.amazon.com/hands-on/latest/create-continuous-delivery-pipeline/images/clone-repo-github-code-dropdown-options.png)

1. Open a terminal

   If you're on a Mac or Linux computer, open your terminal. If you're on Windows, launch Git Bash. 

1. Clone the repo

   In the terminal or Bash platform, whichever you are using, enter the following command and paste the URL you just copied when you clicked the clipboard icon. Be sure to change "YOUR-USERNAME" to your GitHub username. You should see a message in your terminal that starts with **Cloning into.** This command creates a new folder that has a copy of the files from the GitHub repo. 

   ```
   git clone https://github.com/YOUR-USERNAME/aws-elastic-beanstalk-express-js-sample
   ```

1. Modify the app.js file

   In the new folder there is a file named **app.js.** Open** app.js** in your favorite code editor. 

   Change the message in line 5 to say something other than "Hello World\$1" and save the file. 

1. Commit and push the change

   Go to the folder created with the name **aws-elastic-beanstalk-express-js-sample/** and **Commit** the change with the following commands: 

   ```
   git add app.js
   git commit -m "change message"
   ```

   Push the local changes to the remote repo hosted on GitHub with the following command. Note that you need to configure **Personal access tokens (classic)** under **Developer Settings** in GitHub for remote authentication. 

   ```
   git push
   ```

### Step 3: Test your changes
<a name="test-your-changes"></a>
+ Verify the repo updated

  In your browser window, open [GitHub](https://github.com/). 

  In the left navigation panel, under **Repositories,** select **aws-elastic-beanstalk-express-js-sample**. 

  Choose the **app.js** file. The contents of the file, including your change, should be displayed. 

#### Application architecture
<a name="application-architecture"></a>

Here is what our architecture looks like right now. 

We have created a code repository containing a simple web app. We will be using this repository to start our continuous delivery pipeline. It's important to set it up properly so we push code to it. 

![\[Diagram showing users connecting to a Git repository, with an arrow pointing from users to the Git icon, and a labeled AWS Cloud box, representing setup or workflow from users via git to AWS Cloud.\]](http://docs.aws.amazon.com/hands-on/latest/create-continuous-delivery-pipeline/images/cloud-git-repository-users-diagram-acffbad.png)
