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!