Module 3: Your First Repository (Hands-on!)¶
🎯 What you'll learn: Create a Git repository from scratch, make changes, stage them, commit them, and explore your history — all on your own machine.
🔧 This is a hands-on module! You'll run real commands and see real output. Follow along step by step.
🛠️ Before We Start¶
Verify Git is Installed¶
Open a terminal (Windows Terminal / PowerShell) and run:
You should see something like:
If you get an error, download Git from git-scm.com and install with default settings.
Tell Git Who You Are¶
Git stamps every commit with your name and email. Set this up once:
To check your current settings:
Why does Git need my name?
Every commit is stamped with author info — it's how teams know who changed what. This is stored locally in your Git config, not sent anywhere.
Step 1: Create a Project Folder¶
Let's create a practice folder for our Cloud Café project:
# Create the folder
New-Item -ItemType Directory -Path "C:\ssClawy\git-practice\cloud-cafe" -Force
# Go into it
cd C:\ssClawy\git-practice\cloud-cafe
Right now this is just a normal empty folder. Git doesn't know about it yet.
Step 2: git init — Create a Repository¶
This is the magic command that turns a normal folder into a Git repository:
Output:
What just happened? Git created a hidden .git folder inside your project. This is Git's brain — it stores all history, config, and tracking data.
📁 cloud-cafe/
└── .git/ ← Git's hidden brain (created by git init)
├── objects/ ← where snapshots (commits) are stored
├── refs/ ← branch pointers
├── HEAD ← "you are here" pointer
└── config ← repository settings
Never delete or edit the .git folder
This folder IS your repository. Delete it, and all your Git history is gone. Git commands handle everything — you never need to touch this folder directly.
Step 3: git status — Your Best Friend¶
git status is the command you'll use more than any other. It tells you what's happening:
Output:
This tells us:
- We're on the main branch (the default)
- No commits yet (empty history)
- No files to track (the folder is empty)
💡 Tip: When in doubt, run
git status. It always tells you where you are and what to do next.
Step 4: Create Your First File¶
Let's create a menu for the Cloud Café:
# Create menu.md with some content
@"
# ☕ Cloud Café Menu
## Hot Drinks
- Flat White — `$5.00`
- Long Black — `$4.50`
- Cappuccino — `$5.50`
## Cold Drinks
- Iced Latte — `$6.00`
- Cold Brew — `$5.50`
"@ | Set-Content menu.md
Now run git status again:
Output:
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
menu.md
nothing added to commit but untracked files present (use "git add" to track)
Git sees the new file but it's untracked (red) — Git doesn't know about it yet. It even tells you what to do: "use git add to track."
Step 5: git add — Stage the File¶
Let's add menu.md to the Staging Area (the shopping cart):
Check the status:
Output:
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: menu.md
Notice the change? menu.md moved from red (untracked) to green (staged). It's in the cart, ready to be committed.
Step 6: git commit — Save the Snapshot¶
Now let's save our first snapshot:
Output:
[main (root-commit) abc1234] Initial menu for Cloud Café
1 file changed, 11 insertions(+)
create mode 100644 menu.md
Congratulations — you just made your first commit! 🎉
Let's break down the output:
| Part | Meaning |
|---|---|
main |
The branch name |
root-commit |
This is the very first commit (no parent) |
abc1234 |
The unique commit ID (first 7 characters of the hash) |
Initial menu for Cloud Café |
Your commit message |
1 file changed, 11 insertions(+) |
What changed in this commit |
Now run git status:
Output:
"Working tree clean" — everything is committed. Your project is in sync.
Step 7: Make Changes and See the Diff¶
Let's add a new drink to the menu. Open menu.md and add Mocha:
# Add a new item
(Get-Content menu.md) -replace '(- Cappuccino.*)', "`$1`nMocha — ``$`6.00``" | Set-Content menu.md
Or simply add it manually. Either way, now run:
This shows you exactly what changed since the last commit:
--- a/menu.md
+++ b/menu.md
@@ -5,6 +5,7 @@
- Flat White — $5.00
- Long Black — $4.50
- Cappuccino — $5.50
+- Mocha — $6.00
The + prefix means "this line was added." A - prefix means "this line was removed."
| Symbol | Meaning |
|---|---|
+ (green) |
Line was added |
- (red) |
Line was removed |
| No prefix | Line is unchanged (shown for context) |
Step 8: git log — See Your History¶
After making a few commits, you can see your entire history:
Output:
commit abc1234... (HEAD -> main)
Author: Sutheesh <susanth@...>
Date: Mon Apr 6 15:15:00 2026 +1200
Initial menu for Cloud Café
For a compact view:
Output:
After more commits, you'll see the full timeline:
a3f7b2c (HEAD -> main) Added Mocha to hot drinks
2d8e9a3 Added opening hours
b5c3f71 Added food section
abc1234 Initial menu for Cloud Café
Step 9: The Full Workflow — Practice Round¶
Now let's practice the complete workflow. Create another file:
# Create an hours file
@"
# ⏰ Cloud Café Hours
| Day | Hours |
|-----|-------|
| Monday–Friday | 7:00 AM – 5:00 PM |
| Saturday | 8:00 AM – 3:00 PM |
| Sunday | Closed |
"@ | Set-Content hours.md
Now run through the full Git workflow:
# 1. Check what's changed
git status
# 2. Stage the new file
git add hours.md
# 3. Check the staging area
git status
# 4. Commit with a clear message
git commit -m "Added opening hours for Cloud Café"
# 5. See the history
git log --oneline
📊 Visual Git Tools¶
So far we've used Git through the command line. But visual tools exist that show the same information with a graphical interface:
GitHub Desktop¶
A free Windows app by GitHub. Point-and-click interface for staging, committing, and pushing:
- Download: desktop.github.com
- Shows changed files with colour coding
- Visual diff viewer
- One-click commit and push
VS Code Git Panel¶
If you use VS Code, Git is built into the sidebar:
- Source Control icon (branch symbol) in the left sidebar
- Shows changed files, staging area, commit input
- Inline diff viewer
- Great for when you're already editing code in VS Code
GitKraken / SourceTree¶
More advanced visual tools that show branch diagrams:
- Beautiful visual timelines of commits and branches
- Drag-and-drop merging
- Great for understanding complex histories
When to Use What?¶
| Tool | Best For |
|---|---|
| Command line (what we're learning) | Full power, automation, scripting |
| GitHub Desktop | Beginners, simple workflows |
| VS Code panel | When you're already in VS Code |
| GitKraken | Visual branch management |
| github.com | Browsing history, reviewing PRs |
Learn the commands first
We're learning Git through the command line because it gives you the deepest understanding. Once you know the commands, visual tools are just a prettier way to run them. You can switch to visual tools later!
✅ Module 3 Summary¶
┌───────────────────────────────────────────────────────┐
│ Module 3 Recap │
├───────────────────────────────────────────────────────┤
│ │
│ git init → Create a new repository │
│ git status → See what's changed (USE THIS A LOT) │
│ git add <file> → Stage a file (add to cart) │
│ git add -A → Stage ALL changes │
│ git commit -m → Save a snapshot with a message │
│ git diff → See what changed (line by line) │
│ git log → See commit history │
│ │
│ 🔧 Practice folder: C:\ssClawy\git-practice\ │
│ │
│ ➡️ Next: Module 4 — What is GitHub? │
└───────────────────────────────────────────────────────┘
🧪 Module 3 Quiz¶
Q1: What does git init do?
It creates a new Git repository in the current folder by adding a hidden .git directory. This is where Git stores all history, configuration, and tracking data. You only run this once per project.
Q2: What's the difference between an untracked file and a staged file?
Untracked = Git doesn't know about the file yet (it's new, never been added). Staged = the file has been added to the Staging Area with git add and is ready to be committed. In git status, untracked/modified files show in red; staged files show in green.
Q3: You made changes to 3 files but only want to commit 2. What commands do you run?
The third file stays in the Working Directory — changed but not staged or committed. You can commit it separately later.Q4: What does git diff show you?
It shows the line-by-line differences between your Working Directory and the last commit. Lines with + were added, lines with - were removed. This helps you review changes before staging and committing.
Q5: After running git status and seeing 'nothing to commit, working tree clean' — what does that mean?
It means ALL your changes have been committed. Your Working Directory matches the latest commit in the Repository. There's nothing new to stage or save.
➡️ What's Next?¶
In Module 4: What is GitHub?, you'll learn the difference between Git and GitHub, create a remote repository, and understand how local and remote work together. Plus: GitHub.dev, Codespaces, and the GitHub tour!