Module 1: Set Up Git Repo
In this module you will set up a git repo for your code so it can be easily accessed over the Internet.
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, but there are other Git-compatible options you can use including AWS 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 Learn
- Fork a GitHub repository to create a new one
- Store code and metadata in GitHub
- Interact with a code repository using Git
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 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.
Fork the starter repo
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 find step-by-step instructions here.
- In a new browser tab navigate to GitHub and make sure you are logged into your account.
- In that same tab, open the aws-elastic-beanstalk-express-js-sample repo.
- Click the white "Fork" button on the top right corner of the screen. Next, you'll see a small window asking you where you would like to fork the repo.
- Click on your account. After a few seconds, your browser will display a copy of the repo on your account.
Push a change to your new repo
- Click 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, click on the "Use HTTPS" link.
- Click the white button with a clipboard icon on it (to the right of the URL).
4. If you're on a Mac or Linux computer open your terminal, and if you're on Windows launch Git BASH.
5. In the app you just launched type the following command and paste the URL you just copied in Step 2 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
6. In the new folder there is a file named "app.js." Open "app.js" in your favorite code editor.
7. Change the message in line 5 to say something other than "Hello World!" and save the file.
8. Commit the change with the following commands:
git add app.js git commit -m "change message"
9. Push the local changes to the remote repo hosted on GitHub with the next command:
Test your changes
- In your browser window open GitHub.
- On the left navigation panel, under "Repositories" click on the one named aws-elastic-beanstalk-express-js-sample.
- Click on the "app.js" file. The contents of the file, including your change, should be displayed.
Here is what our architecture looks like right now:
We have created a code repository containing a simple Hello World! web app. We will be using this repository as the trigger for our continuous delivery pipeline so it is important it is set up properly and we can successfully push code to it.