Git & GitHub for Beginners (Amazon Linux 2023): Fork, Branch, Commit, Pull Request (Walkthrough)

Source: Dev.to | Jan 31, 2026 (UTC)

This is a beginner-friendly, step-by-step; Git + GitHub walkthrough you can follow on an AWS EC2 instance running Amazon Linux 2023 (SSH access).

By the end, you will be able to:

  • Understand Git vs GitHub
  • Create a clean project workspace
  • Install and configure Git locally per repo (no global settings)
  • Generate and add a GitHub SSH key (with troubleshooting)
  • Fork an upstream repository
  • Clone your fork to your VM
  • Create a feature branch
  • Edit index.html + style.css
  • Commit changes, push to your fork, and open a Pull Request
  • Understand what a PR does (and does not do) to the original repo
  • Optionally publish your page under Nginx as /your-github-project/ alongside an existing React deployment

Learning context: This walkthrough supports self-paced learning and collaboration workflows using open-source materials.

Table of Contents

Prerequisites

You need:

  • An AWS EC2 instance running Amazon Linux 2023
  • SSH access to that instance
  • A GitHub account
  • Basic terminal comfort (copy/paste commands is fine)

Optional (but helpful):

  • A text editor like nano (I used vim)

Git vs GitHub

Git: a version control tool that runs on your computer (or VM). It tracks changes to files over time.

GitHub: a website that hosts Git repositories online so you can collaborate, share, and open pull requests.

Simple analogy:

  • Git = the save/history engine
  • GitHub = the online place where projects live and collaboration happens

Step 1 — Connect to Your VM

From your local computer, connect to your EC2 instance:

ssh -i /path/to/your-key.pem ec2-user@YOUR_PUBLIC_IP

Enter fullscreen mode

Exit fullscreen mode

What the pieces mean:

Once logged in, you’re working on the VM.

Step 2 — Install Git (Amazon Linux 2023)

Update system packages:

sudo dnf update -y

Enter fullscreen mode

Exit fullscreen mode

Install Git:

sudo dnf install -y git

Enter fullscreen mode

Exit fullscreen mode

Verify:

git --version

Enter fullscreen mode

Exit fullscreen mode

Flag notes:

Step 3 — Create a Clean Project Workspace

Create a parent folder for all repos:

mkdir -p ~/projects cd ~/projects

Enter fullscreen mode

Exit fullscreen mode

Important rule:

Step 4 — Local Git Config (Per Repository Only)

You asked an important question: “Global vs local?”

For this walkthrough, we use local config only to keep things isolated.

You can only set local config after a repo exists (after git init or git clone).

We’ll do it after cloning in Step 7.

Step 5 — Generate a GitHub SSH Key

Should you add a passphrase?

Recommended: Yes (especially on cloud VMs). A passphrase protects your private key if the VM is compromised.

Generate an SSH key:

ssh-keygen -t ed25519 -C "[email protected]"

Enter fullscreen mode

Exit fullscreen mode

What flags mean:

When prompted for a file location:

When prompted for passphrase:

Start the SSH agent and add your key:

eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519

Enter fullscreen mode

Exit fullscreen mode

Copy the public key (this is what GitHub needs):

cat ~/.ssh/id_ed25519.pub

Enter fullscreen mode

Exit fullscreen mode

Now on GitHub:

Test connectivity:

ssh -T [email protected]

Enter fullscreen mode

Exit fullscreen mode

Expected result:

Common Error: “Key is invalid…”

If GitHub says:

“Key is invalid. You must supply a key in OpenSSH public key format”

It almost always means one of these:

Fix checklist:

  1. Make sure you copied only the output of:

cat ~/.ssh/id_ed25519.pub

Enter fullscreen mode

Exit fullscreen mode

  1. It should be a single line starting with:
  2. Do NOT paste:

Step 6 — Fork the Assignment Repo on GitHub

Open the upstream repository in your browser:

Click:

This creates your own copy under your account (example):

Why forks matter:

Step 7 — Clone Your Fork to the VM

In your VM terminal:

cd ~/projects git clone [email protected]:yourusername/Week-2---Git-GitHub-Assignment.git cd Week-2---Git-GitHub-Assignment

Enter fullscreen mode

Exit fullscreen mode

Explanation:

Check remotes:

git remote -v

Enter fullscreen mode

Exit fullscreen mode

You should see origin pointing to your fork.

Set local git config in THIS repo

Now that you’re inside the repo, set local config:

git config user.name "Your Username" git config user.email "[email protected]"

Enter fullscreen mode

Exit fullscreen mode

Verify local settings:

git config --list --local

Enter fullscreen mode

Exit fullscreen mode

Step 8 — Add Upstream (What It Does)

Add the original repo as upstream:

git remote add upstream https://github.com/pravinmishraaws/Week-2---Git-GitHub-Assignment.git git remote -v

Enter fullscreen mode

Exit fullscreen mode

What this does:

It does NOT:

Step 9 — Create a Feature Branch

Create and switch to a new branch:

git switch -c your-branch-name

Enter fullscreen mode

Exit fullscreen mode

Why branch?

How to Confirm You’re on the Right Branch

Use any of these:

git status

Enter fullscreen mode

Exit fullscreen mode

Look for: On branch ...

Or:

git branch

Enter fullscreen mode

Exit fullscreen mode

The branch with * is your current branch.

Or quick output:

git branch --show-current

Enter fullscreen mode

Exit fullscreen mode

Why You Might See master Instead of main

Some repos use master as the default branch instead of main.

This is normal.
There is no functional difference for this assignment.

Use whatever default branch exists in your repo.

Step 10 — Make Your Changes (index.html + style.css)

Edit your files:

vim index.html vim style.css

Enter fullscreen mode

Exit fullscreen mode

Vim basics:

Make your updates (student details + theme).

Step 11 — Stage, Commit, and Review History

Check what changed:

git status

Enter fullscreen mode

Exit fullscreen mode

Preview changes line-by-line:

git diff

Enter fullscreen mode

Exit fullscreen mode

Stage (add to the “next commit”):

git add index.html style.css

Enter fullscreen mode

Exit fullscreen mode

Commit (save snapshot):

git commit -m "Your descriptive commit note"

Enter fullscreen mode

Exit fullscreen mode

View history:

git log --oneline

Enter fullscreen mode

Exit fullscreen mode

Step 12 — Push Your Branch to GitHub

Push your branch:

git push -u origin your-branch-name

Enter fullscreen mode

Exit fullscreen mode

What -u does:

Step 13 — Open a Pull Request (PR)

On GitHub, go to your fork repo page.
You should see a prompt like:

Create a PR:

Does a PR change the original repo?

No.

A PR is a request to merge.
The upstream repo does not change until:

Suggested PR Description

You can paste this:

This pull request is for learning purposes only. The goal is to practice the GitHub pull request workflow, understand how forks and branches are compared, and learn how collaboration works in a real repository. The changes are intentionally simple and focused on hands-on learning rather than introducing new features. Thank you, Pravin, for providing open-source learning materials and repositories that make it easier to learn Git and GitHub through real practice.

Enter fullscreen mode

Exit fullscreen mode

Step 14 — Keep Your Fork Updated (Sync Upstream)

If upstream changes later:

git fetch upstream

Enter fullscreen mode

Exit fullscreen mode

Merge upstream changes into your default branch (example uses master):

git switch master git merge upstream/master

Enter fullscreen mode

Exit fullscreen mode

Push updates to your fork:

git push origin master

Enter fullscreen mode

Exit fullscreen mode

Notes:

Debugging Example: UI Broke After CSS Update

Scenario:

Find recent commits that touched the file:

git log -- style.css

Enter fullscreen mode

Exit fullscreen mode

Compare changes:

git diff

Enter fullscreen mode

Exit fullscreen mode

If you know the commit hash that introduced the issue:

git diff <good_commit_hash> <bad_commit_hash>

Enter fullscreen mode

Exit fullscreen mode

Why this matters (DevOps mindset):

Optional: Publish Under Nginx as /your-github-project/

This is optional, but it’s a great real-world deployment skill:

Reference article (React + Nginx deployment on Amazon Linux):
https://dev.to/ldwit/deploying-a-react-app-with-nginx-on-aws-amazon-linux-beginner-walkthrough-3h76

Confirm your Nginx root

Run:

sudo nginx -T | grep -i root

Enter fullscreen mode

Exit fullscreen mode

In the example setup, the active root was:

Create a folder for your static page

sudo mkdir -p /var/www/react-app/current/your-github-project

Enter fullscreen mode

Exit fullscreen mode

Copy your assignment files into that folder

From your repo folder:

sudo cp index.html style.css /var/www/react-app/current/your-github-project/

Enter fullscreen mode

Exit fullscreen mode

Fix permissions (avoid 403 errors)

sudo chmod -R 755 /var/www/react-app/current/your-github-project

Enter fullscreen mode

Exit fullscreen mode

Reload Nginx safely

sudo nginx -t sudo systemctl reload nginx

Enter fullscreen mode

Exit fullscreen mode

Test it

Open:

Key Takeaways

Credits

For further actions, you may consider blocking this person and/or reporting abuse

Залишити відповідь

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *

Читайте також