0% found this document useful (0 votes)
6 views17 pages

Connect GitHub Repo with AWS EC2

The document outlines a project by Joba Amunigun as part of a 7 Day DevOps Challenge, focusing on connecting a web application to a GitHub repository using AWS EC2. Key concepts covered include version control with Git, GitHub authentication using personal access tokens, and the creation of a README file in Markdown format. The project aims to build a strong foundation for a CI/CD pipeline while providing hands-on experience with cloud-based development and version control integration.

Uploaded by

jojoasta381
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views17 pages

Connect GitHub Repo with AWS EC2

The document outlines a project by Joba Amunigun as part of a 7 Day DevOps Challenge, focusing on connecting a web application to a GitHub repository using AWS EC2. Key concepts covered include version control with Git, GitHub authentication using personal access tokens, and the creation of a README file in Markdown format. The project aims to build a strong foundation for a CI/CD pipeline while providing hands-on experience with cloud-based development and version control integration.

Uploaded by

jojoasta381
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

nextwork.

org

Connect a GitHub
Repo with AWS
Joba Amunigun
[Link]
Joba Amunigun
NextWork Student [Link]

Introducing Today's Project!


I’m super excited because this is Day TWO of the 7 Day DevOps Challenge! Today,
I’ll be learning how to store my web application’s code in a Git repository. In this
project, I will demonstrate how to set up Git and GitHub, connect my web app project
to a GitHub repo, and practice pushing code so my changes are safely tracked in the
cloud. I’m doing this project to learn the fundamentals of version control, get
comfortable with GitHub as the source of truth for my code, and lay the groundwork
for the CI/CD pipeline I’ll be building throughout the rest of this challenge.

Key tools and concepts


Services I used were: AWS EC2 to host my web application, GitHub for version control
and remote code storage, and VS Code as a local IDE to connect to the EC2 instance
and edit files remotely. Key concepts I learnt included version control with Git,
initializing a repository, staging and committing changes, connecting to remote
repositories, pushing changes to GitHub, GitHub authentication with personal access
tokens, creating and formatting [Link] files using Markdown, secure SSH
connections to remote servers, and using Apache Maven as a package manager for
Java projects.

Project reflection
This project took me approximately 7hours to complete plus troubleshooting time and
reading to understand the new concepts. The most challenging part was configuring
the connection between my local repository and the remote GitHub repository while
ensuring all changes were tracked properly. It was most rewarding to see my changes
successfully pushed to GitHub and to understand how version control integrates with
cloud-based development.

I did this project because I wanted to gain hands-on experience with cloud-based
development and understand how to integrate version control with AWS services. This
project also helps me build a strong foundation for creating automated CI/CD
Joba Amunigun
NextWork Student [Link]

This project is part two of a series of DevOps projects where I'm building a CI/CD
pipeline! I'll be working on the next project Secure Packages with CodeArtifact
Joba Amunigun
NextWork Student [Link]

Git and GitHub


Git is a version control system that tracks changes to your code over time. It acts like a
“time machine” for your project, letting you see who changed what, revert to earlier
versions if something breaks, and collaborate with others efficiently. How did I install
it? I installed Git directly on my EC2 instance using the terminal. First, I updated the
package manager: sudo yum update -y Then, I installed Git: sudo yum install git -y
Finally, I verified the installation with: git --version This confirmed Git was successfully
installed and ready to use.

GitHub is a cloud-based platform for storing and sharing code that uses Git to track
version history. It lets developers access their projects from anywhere, collaborate
with others, and manage changes in an organized way. I'm using GitHub in this project
to store my web app online, track changes to my code, and back up my work from the
EC2 instance. Even though my code is already on a cloud server, GitHub provides a
user-friendly interface for version control and collaboration, making it easier to
manage updates and share my project with others.
Joba Amunigun
NextWork Student [Link]
Joba Amunigun
NextWork Student [Link]

My local repository
A Git repository (or “repo”) is a storage space for your project that Git tracks. It
contains all your project files, their complete history of changes, and metadata about
those changes. Think of it like a folder with a built-in time machine: every time you
make changes and commit them, Git takes a snapshot of your files. This allows you to:
Revert to an earlier version if something breaks. Track who made changes and when.
Collaborate with others by merging changes from multiple developers. In short, a Git
repository keeps your code safe, organized, and version-controlled.

"git init" is a command that creates a local Git repository in your project folder,
enabling Git to track all changes made to the files in that folder. I ran git init inside my
"nextwork-web-project" folder on my EC2 instance. This means that from now on, any
changes I make to my web app files are tracked locally. A local repository is only
visible to me until I connect it to a remote repository like GitHub and Vs Code, where
the code can be shared and backed up. Running git init is the first step in using Git for
version control in this project.

A branch in Git is a parallel version of your project that allows you to work on changes
or new features independently from the main codebase. This way, you can
experiment, fix bugs, or add features without affecting the main branch (usually called
master or main). After running git init, the response from the terminal was a message
about the default branch name, often suggesting master or giving the option to name
it something else like main or development. This yellow text is just Git letting me know
about the initial branch setup.
Joba Amunigun
NextWork Student [Link]
Joba Amunigun
NextWork Student [Link]

To push local changes to GitHub, I ran


three commands
git add
The first command was: git remote add origin [Link]
[Link] This command connects your local Git repository with your GitHub
repository. remote tells Git that you want to manage a connection to a remote
repository (a repository stored online, like on GitHub). add means you’re adding a new
remote. origin is the conventional name for the remote repository—it acts like a
bookmark for your GitHub URL. The URL ([Link] points Git to the exact
location of your GitHub repository. Essentially, this command links your local project to
the GitHub repo, so you can push changes from your EC2 instance to GitHub. Then i
added "git add ." What it means: git add tells Git to stage changes—that is, prepare
them to be committed. The . (dot) means all files in the current directory and its
subdirectories will be [Link] other words, this command marks all your modified or
new files in the project folder to be included in the next commit

git commit
The second command you ran was: git commit -m "Updated [Link] with new
content" What it means: git commit saves the staged changes as a snapshot in your
project’s version history. This creates a record of what your project looked like at that
moment. The -m flag lets you add a commit message directly in the command, which
describes what changes you made. In this case, "Updated [Link] with new content"
explains what this snapshot contains. Using -m is a shortcut so you don’t have to open
a separate editor to write the commit message. It helps you keep your commits
organized and understandable.

git push
The third command you ran was: git push -u origin master What it means: git push
uploads your committed changes from your local repository to the remote repository
Gi H b i i i h i d li ( Gi H b )
Joba Amunigun
NextWork Student [Link]

Authentication
When I commit changes to GitHub, Git asks for my credentials because it needs to
verify that I have permission to push changes to the remote repository. This is Git’s
way of making sure that only authorized users can update the code in the repository.
Since GitHub no longer accepts passwords over HTTPS for security reasons, I need to
use a personal access token instead of my account password. This token acts like a
secure, unique password that lets Git authenticate me safely and push my changes to
GitHub.

Local Git identity


Git needs my name and email because every commit I make is like a permanent entry
in a logbook. Each entry must show: Who made the change → your name How to
identify/contact that person → your email So your commits look like: commit 123abc
Author: Joba <you@[Link]> Date: Mon Aug 25 12:34:56 2025 Fix bug in login
page Without a name and email, Git wouldn’t know how to label the author of each
commit. That’s why Git asks you to set them: git config --global [Link] "Your
Name" git config --global [Link] "your@[Link]" This is not for spam or
marketing — it’s just metadata that travels with your commits so others can see who
wrote what.

placeholder
Running git log showed me that... 👉 It lists the history of commits in your repository,
starting from the most recent.
Joba Amunigun
NextWork Student [Link]

For each commit, you see: The commit hash (a unique ID like 5c34b56...) The author’s
name and email The date and time of the commit The commit message (what change
was made) Example: commit 792bc23c18b0f5f8a84e6f54d4f2a3b0c2e12345 Author:
Joba <0xjoba@[Link]> Date: Mon Aug 25 18:42:10 2025 Add .gitignore to
exclude large files So basically, git log is like the diary of your project’s changes ✍️
Joba Amunigun
NextWork Student [Link]

GitHub tokens
GitHub authentication failed when I entered my password because GitHub no longer
allows password authentication for HTTPS connections. For security reasons,
passwords can be intercepted, so GitHub requires a personal access token (PAT)
instead. The token is a secure, unique string that acts like a password and allows Git to
authenticate me safely when pushing or pulling from a repository.

A GitHub token is a unique, secure string of characters that acts like a password for
authenticating with GitHub. It allows you to access your repositories, push or pull
changes, and interact with GitHub safely without using your actual account password.
I’m using one in this project because GitHub no longer allows password authentication
over HTTPS, so the token is the secure way for my local Git repository on the EC2
instance to connect and push changes to my GitHub repository.

I could set up a GitHub token by going to my GitHub account settings, navigating to


“Developer settings” → “Personal access tokens” → “Tokens (classic)”, and then
clicking “Generate new token”. I selected the necessary permissions (scopes) for
repository access, generated the token, and copied it to use for authenticating my
local Git repository so I could push and pull changes safely.
Joba Amunigun
NextWork Student [Link]
Joba Amunigun
NextWork Student [Link]

Making changes again


src/main/webapp/[Link] I wanted to see Git working in action, so I… I added a new
line to [Link] to confirm that changes made locally could be staged, committed,
and pushed to GitHub. I couldn't see the changes in my GitHub repo initially because…
Saving the file in VSCode only updated my local repository. I needed to run git add .,
git commit -m "Add new line to [Link]", and git push to send the changes to GitHub.

I finally saw the changes in my GitHub repo after staging the modified file with git add
., committing the changes with git commit -m "Add new line to [Link]", and then
pushing them to GitHub using git push. This sequence sent my local updates to the
remote repository, making them visible on GitHub.
Joba Amunigun
NextWork Student [Link]
Joba Amunigun
NextWork Student [Link]

Setting up a READMe file


As a finishing touch to my GitHub repository, I added a README file, which is a
document that introduces and explains my project, including what it does, how to set it
up, and how to use it. I added a README file by creating a new blank file with the
touch [Link] command in my EC2 instance, then editing it to include project
details, and finally staging, committing, and pushing it to GitHub.

My README is written in Markdown because Markdown allows me to format text in a


clean, readable way for GitHub. Special characters can help me format text in
Markdown, such as # for headers, ** for bold, * for italics, - or * for bullet points, [link
text](URL) for hyperlinks, and triple backticks ``` for code blocks. These symbols make
it easy to structure and style documentation without using complex software.

My README file has 6 sections that outline: Introduction – Explains the purpose of the
project and how it contributes to my learning and career growth. Technologies – Lists
the tools and services I used, along with challenges I faced and solutions I found.
Setup – Step-by-step instructions for getting the project running, including
troubleshooting tips for common issues. Contact – My email, LinkedIn profile, and
professional profile photo for networking or collaboration. Table of Contents – Quick
navigation to different sections of the README. Conclusion – Summarizes the project
and acknowledges any resources or guides that helped me complete it.
Joba Amunigun
NextWork Student [Link]
[Link]

The place to learn &


showcase your skills
Check out [Link] for more projects

You might also like