Complete Beginner Guide
Git, GitHub & GitHub Actions for CI/CD
Learn version control, collaboration, and automated pipelines — explained in plain English, with hands-on examples and 100 quiz questions to test your knowledge.
1. Prerequisites & Setup
Everything you need before writing your first commit.
Before diving into Git and GitHub, make sure you have a few basics in place. Think of this like gathering ingredients before cooking — you don't need to be an expert chef, but you do need a kitchen.
What You Should Know
- Basic computer skills — creating folders, installing software, using a text editor.
- Command line comfort (helpful, not required) — we'll show you the commands, but GUI tools like GitHub Desktop exist if you prefer clicking over typing.
- A free GitHub account — sign up at github.com.
Tools to Install
A code editor
VS Code, Cursor, or any editor you like. You'll use it to write code and view diffs.
A modern web browser
For browsing GitHub, reviewing pull requests, and checking GitHub Actions run logs.
[[VISUAL_PLACEHOLDER: Diagram showing the developer toolchain — editor, terminal with Git, browser with GitHub, all connected by arrows]]
First-Time Git Configuration
Git needs to know who you are so it can label your work. Run these once after installing Git:
# Tell Git your name and email
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
# Set default branch name to 'main'
git config --global init.defaultBranch main
2. CI/CD: The Big Picture
Why automation matters and how it fits into modern software delivery.
Imagine you're baking cookies for a bake sale. Every time you change the recipe, you'd taste-test before selling — that's quality checking. If the cookies pass, you'd box them up and deliver them — that's delivery. CI/CD automates both steps for software.
CI — Continuous Integration
Every time someone pushes code, automated tests run to catch bugs early. Like a spell-checker that runs on every paragraph you write.
CD — Continuous Delivery / Deployment
Once tests pass, code can be automatically packaged and deployed to staging or production. Like an assembly line that ships products once they pass inspection.
[[VISUAL_PLACEHOLDER: CI/CD pipeline flowchart — Developer pushes code → CI runs tests → CD deploys to server → Users see update]]
Why Teams Use CI/CD
- Catch bugs faster — broken code is detected within minutes, not days.
- Ship confidently — if the pipeline is green, you know the basics work.
- Reduce manual work — no more "works on my machine" deploy rituals at 2 AM.
- Enable collaboration — many developers can work in parallel without stepping on each other.
Where Git, GitHub & Actions Fit In
Git tracks every change to your code. GitHub hosts that history online and lets teams collaborate. GitHub Actions is GitHub's built-in automation engine — it watches for events (like a push) and runs your CI/CD pipeline in the cloud.
3. Git: Version Control Basics
Understanding snapshots, history, and the local repository.
Git is a version control system. Think of it as an unlimited "Undo" button for your entire project — but smarter. Instead of one undo, Git saves a timeline of every saved state (called a commit), who made it, and why.
[[VISUAL_PLACEHOLDER: Timeline diagram showing commits as dots on a line, each labeled with a message and author]]
Key Concepts
Repository (repo)
A folder that Git tracks. It contains your files plus a hidden .git directory with the full history.
Working Directory → Staging → Commit
You edit files (working directory), choose what to save next (git add → staging area), then permanently snapshot (git commit).
Commit
A saved checkpoint with a unique ID (hash), a message describing the change, and a timestamp.
[[VISUAL_PLACEHOLDER: Three-box diagram — Working Directory, Staging Area, Repository — with arrows labeled git add and git commit]]
Essential Commands
# Create a new repo in the current folder
git init
# Check what's changed
git status
# Stage a file
git add index.html
# Commit with a message
git commit -m "Add landing page"
# View commit history
git log --oneline
💡 Tip: Write commit messages like short story titles — "Fix login button color" not "stuff". Future you (and your teammates) will thank you.
4. GitHub: Your Project's Home in the Cloud
From local folders to shared, backed-up repositories.
If Git is the engine, GitHub is the garage where you park and share your project. It's a website (and much more) that stores Git repositories online, adds collaboration tools, and connects to automation like GitHub Actions.
[[VISUAL_PLACEHOLDER: Illustration comparing local Git repo on a laptop vs. remote GitHub repo in the cloud, connected by sync arrows]]
Local vs. Remote
- Local repository — lives on your computer. Fast, works offline.
- Remote repository — lives on GitHub's servers. Backed up, shareable, triggers CI/CD.
- Origin — the default name for your primary remote on GitHub.
Creating & Connecting a Repo
# On GitHub: click "New repository", then locally:
git remote add origin https://github.com/username/my-project.git
git push -u origin main
Core GitHub Features
Track bugs, ideas, and tasks.
Propose and review code changes.
Automate CI/CD workflows.
Host static websites for free.
5. Working with Repositories
Clone, pull, push, and keep your local copy in sync.
Day-to-day GitHub work is a rhythm: pull the latest changes, make edits, commit locally, then push back to GitHub. It's like borrowing a shared notebook, writing your page, and returning it to the shelf.
[[VISUAL_PLACEHOLDER: Sync cycle diagram — pull down → edit → commit → push up, looping between local and remote]]
Clone an Existing Project
git clone https://github.com/username/project.git
cd project
This downloads the entire history — not just the latest files — so you have the full timeline locally.
Daily Sync Commands
# Get latest changes from GitHub
git pull origin main
# Send your commits to GitHub
git push origin main
Handling Merge Conflicts
A merge conflict happens when two people edit the same lines differently. Git pauses and asks you to pick the correct version. Open the conflicted file, look for markers like <<<<<<<, choose the right code, then commit the resolution.
[[VISUAL_PLACEHOLDER: Side-by-side diff view showing conflict markers and resolved merge]]
6. Branching & Collaboration
Parallel timelines for safe, isolated development.
A branch is an independent line of development. Imagine writing a draft chapter in a separate notebook while the published book stays untouched. When the draft is ready, you merge it back into the main story.
[[VISUAL_PLACEHOLDER: Branch diagram — main branch as a straight line, feature branch splitting off and merging back]]
Branch Workflow
# Create and switch to a new branch
git checkout -b feature/login-page
# ... make changes, commit ...
# Push branch to GitHub
git push -u origin feature/login-page
# Switch back to main
git checkout main
Naming Conventions
feature/add-search— new functionalityfix/broken-navbar— bug fixesdocs/update-readme— documentation only
Best practice: Never commit directly to main on team projects. Always use a branch and pull request.
7. Pull Requests & Code Review
How teams propose, discuss, and merge changes safely.
A Pull Request (PR) is a formal proposal: "Here are my changes — please review before merging into main." It's the heart of team collaboration on GitHub, and it's where CI pipelines often run automatically.
[[VISUAL_PLACEHOLDER: Pull request UI mockup showing changed files, review comments, and CI check status]]
The PR Lifecycle
- Create a branch and push your commits.
- Open a Pull Request on GitHub, describing what and why.
- Automated CI checks run (tests, linting, build).
- Teammates review code and leave comments.
- Once approved and checks pass, merge into
main. - Delete the feature branch — it's served its purpose.
Writing Good PR Descriptions
Include context a reviewer needs: the problem you're solving, how you solved it, and how to test it. Link related issues with keywords like Fixes #42 to auto-close them on merge.
8. Introduction to GitHub Actions
Your project's robot assistant in the cloud.
GitHub Actions lets you automate tasks when things happen in your repository — push code, open a PR, schedule a cron job. GitHub spins up a temporary virtual machine (called a runner), runs your instructions, and reports pass/fail.
[[VISUAL_PLACEHOLDER: GitHub Actions architecture — Event triggers Workflow → Jobs → Steps on Runners]]
Core Terminology
.github/workflows/).
push, pull_request).
Hello World Workflow
# .github/workflows/hello.yml
name: Hello CI
on: [push]
jobs:
greet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Hello from GitHub Actions!"
9. Building CI Pipelines
Automated testing and quality gates on every change.
A CI pipeline typically: checks out your code, installs dependencies, runs linters, runs tests, and maybe builds the project. If any step fails, the workflow turns red and the PR is blocked from merging.
[[VISUAL_PLACEHOLDER: CI pipeline stages — Checkout → Install → Lint → Test → Build, with pass/fail indicators]]
Example: Node.js CI
name: Node CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm test
Matrix Builds
Test across multiple versions simultaneously using a strategy matrix. For example, run tests on Node 18 and Node 20 in parallel — catching version-specific bugs early.
10. CD, Deployment & GitHub Pages
From green CI checks to live websites.
Once CI passes, Continuous Deployment takes over — automatically publishing your site or app. GitHub Pages is perfect for static sites (HTML, CSS, JS) like this very tutorial.
[[VISUAL_PLACEHOLDER: CD flow — merge to main → Actions deploy job → GitHub Pages URL goes live]]
Deploy with GitHub Actions
name: Deploy to Pages
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/upload-pages-artifact@v3
with:
path: '.'
- uses: actions/deploy-pages@v4
Environments & Approvals
For production deploys, use GitHub Environments with required reviewers. Staging can auto-deploy; production waits for a human to click "Approve."
Secrets in CI/CD
Never hardcode API keys in workflow files. Store them in Repository Secrets (Settings → Secrets → Actions) and reference them as ${{ secrets.MY_KEY }}.
[[VISUAL_PLACEHOLDER: Secrets flow diagram — encrypted in GitHub Settings, injected at runtime into workflow, never logged]]
🎉 Congratulations! You now understand the full journey: write code with Git, collaborate on GitHub, automate quality with Actions, and ship with CI/CD.