Skip to main content

Module 3: Git Fundamentals

Primary texts: Pro Git and Git from the Bottom Up
Selective support: GitHub-style pull request workflow only where it clarifies collaboration habits

This module turns Git from a list of commands into a usable model. You are not trying to memorize every command. You are trying to understand what Git is tracking, what state your work is in, and how to move safely between local work, shared history, and recovery.


Before You Start (Diagnostic Prerequisites Assessment)

Prerequisite Competency Verification

Time Limit: 20 minutes, closed-book
Format: Short diagnostic with immediate self-correction
Purpose: Verify that your Module 02 shell skills are strong enough to support command-line Git work

Mastery-Based Progression

Git gets painful when shell basics are shaky. You should be able to navigate directories, inspect files, and read command output cleanly before you try to reason about branches, merges, and recovery.

Diagnostic Questions

Question 1: Tooling Baseline

What command tells you which files in the current directory are visible, including hidden entries such as .git?

a) pwd
b) ls -a
c) cat .git
d) touch .git

Correct Answer: (b)
Why This Matters: Git stores repository metadata in .git, so you need to be comfortable inspecting the filesystem around a repository.

Question 2: Path and Context

You are in ~/projects/app/src and need to move to the repository root ~/projects/app. Which command is correct?

a) cd /app
b) cd ../..
c) cd ..
d) cd ~/app

Correct Answer: (c)
Why This Matters: Git commands are often run from different directories inside a repository, so path awareness matters.

Question 3: Reading Output

Which statement best describes the difference between standard output and standard error?

a) They are two names for the same stream
b) Standard output carries normal program output; standard error carries warnings and failures
c) Standard error is only used by shell builtins
d) Standard output can be redirected, but standard error cannot

Correct Answer: (b)
Why This Matters: Git uses both streams, especially during merge conflicts, failed pulls, and recovery operations.

Question 4: Safe Inspection

You want to see what changed in a file before doing anything destructive. Which mindset is best?

a) Edit first and inspect later
b) Inspect current state before changing it
c) Re-clone the repository immediately
d) Delete the file and recover it later

Correct Answer: (b)
Why This Matters: Good Git workflow starts with reading state accurately before mutating history or the working tree.

Question 5: Reproducible Workflow

Why is command-line Git preferred as a baseline even if GUI tools exist?

a) GUI tools are forbidden on professional teams
b) Command-line Git integrates directly with shell workflow, remote machines, and automation
c) GUI tools cannot show diffs
d) Command-line Git uses different repositories than GUI tools

Correct Answer: (b)
Why This Matters: This module assumes Git is part of your everyday terminal workflow, not a separate visual tool you only open when confused.

Scoring and Progression Gates

Strong Foundation (80-100% correct):

  • Status: Ready to proceed
  • Evidence: You can navigate, inspect, and reason about terminal state without friction
  • Action: Start Cluster 1 and build Git concepts on top of that shell fluency

Developing Foundation (60-79% correct):

  • Status: Review required
  • Evidence: You can work in the shell, but weak spots may turn Git mistakes into bigger mistakes
  • Required Actions:
    1. Revisit Module 02 shell navigation, process, and stream concepts
    2. Repeat the shell workshop page from Module 02
    3. Retake the missed diagnostic questions from memory

Insufficient Foundation (<60% correct):

  • Status: Stop and rebuild shell baseline
  • Evidence: Git commands will feel arbitrary because terminal context is still unstable
  • Required Actions:
    1. Rework Module 02 Cluster 1 before continuing
    2. Practice cd, ls, cat, redirection, and command reading daily
    3. Return only when terminal output no longer feels noisy or mysterious

Automatic Remediation Pathways

Questions 1-2 (Shell and Paths) - If Missed:

Questions 3-4 (Reading State Before Acting) - If Missed:

Question 5 (Workflow Integration) - If Missed:


What This Module Is For

Git is the version-control layer for almost everything you will build from this point onward. That includes homework, projects, pair work, portfolio artifacts, open source contributions, CI pipelines, and professional code review.

This module teaches four things that are easy to confuse if you learn Git only as command trivia:

  • what Git stores
  • what state your repository is currently in
  • how to collaborate without corrupting shared history
  • how to recover when you inevitably make mistakes

Concept Map

How To Use This Module

This module is organized into three clusters. Treat each cluster as a layer of capability.

Cluster 1: Git Foundations

OrderConceptTypeFocus
1Git Mental Model: Snapshots, HEAD, and ReferencesPRIMARYWhat Git stores and why branches are cheap
2The Staging Area and the Commit CycleSUPPORTINGWorking tree, index, git add, and intentional commits
3Reading History, Diffs, and Repository StateSUPPORTINGstatus, diff, log, and commit inspection

Cluster mastery check: Can you explain what is different between the working tree, index, and last commit without guessing?

Cluster 2: Collaboration Mastery

OrderConceptTypeFocus
4Branches, Merge, and RebasePRIMARYTopic branches, integration choices, and branch pointers
5Remotes, Fetch, Pull, and PushSUPPORTINGRemote-tracking branches and synchronization
6Pull Requests, Code Review, and Conflict ResolutionSUPPORTINGShared work, review scope, and resolving conflicts cleanly

Cluster mastery check: Can you move work between local and shared repositories without treating pull as a mystery button?

Cluster 3: Professional Practices

OrderConceptTypeFocus
7Commit Discipline and Everyday WorkflowPRIMARYSmall commits, branch hygiene, and choosing a team workflow
8Recovery with Reset, Stash, and ReflogSUPPORTINGSafe undo, temporary shelving, and recovering lost references

Cluster mastery check: Can you recover from a mistake without panic and explain why your recovery method is safe?

Practice Integration

OrderPractice PathFocus
1Repository State DiagnosticsReading status, diff, and the three-state model accurately
2Branching and Integration LabBranching, merging, rebasing, and conflict practice
3Collaboration and Review LabRemotes, review workflow, and integration discipline
4Code KatasTimed repetition until common Git operations feel automatic

Learning Objectives

By the end of this module you should be able to:

  1. Explain Git as a snapshot-based system with commits, references, and a staging area.
  2. Use status, diff, log, and show to inspect repository state before acting.
  3. Create coherent commits using the index instead of committing a whole messy working tree.
  4. Use topic branches, merges, and rebases deliberately rather than mechanically.
  5. Synchronize with remotes using fetch, pull, and push while understanding what each changes.
  6. Participate in pull request style collaboration and resolve merge conflicts cleanly.
  7. Apply a simple professional workflow with small commits, readable history, and branch hygiene.
  8. Recover from common mistakes using stash, reset, and reflog without losing work.

Outputs

  • one local practice repository showing clean init, add, commit, and log usage
  • one branch exercise repository with at least one merge and one deliberate conflict resolution
  • one remote-backed repository or local two-clone simulation showing fetch, pull, and push
  • one short workflow note explaining your merge vs rebase rule
  • one commit message checklist for future projects
  • one recovery log showing stash and reflog drills

Completion Standard

You have completed Module 3 when you can:

  • explain what a commit, branch, HEAD, and index each represent
  • inspect a repository and tell what is modified, staged, committed, ahead, or behind
  • split unrelated changes into separate commits with intentional messages
  • create, switch, merge, and delete topic branches without confusion
  • explain the difference between fetch and pull in plain language
  • resolve a basic merge conflict and describe why the final result is correct
  • recover from a mistaken reset or shelve unfinished work without panic

Reading Policy

  • The concept pages are the main path.
  • You do not need to read the full books front-to-back to complete this module.
  • Open the local source chunks only when a concept page says Read This Only If Stuck or when you want a deeper model.
  • Prefer hands-on repository practice over passive reading. Git understanding hardens through inspection and repetition.

Source Integration

Git from the Bottom Up

Use this book for the parts of Git that are easy to misuse when you only memorize commands:

  • repository, commit, branch, and HEAD as actual model elements
  • why the index exists
  • what reset, stash, and reflog are really doing
  • why rebase changes history and when that matters

Pro Git

Use this book for the practical daily workflow:

  • repository creation and file lifecycle
  • status, diff, log, and history inspection
  • branches, remotes, and tracking branches
  • pull request flow, collaboration patterns, and conflict handling

Use Reference and Selective Reading when a concept still feels unstable after practice.


Rich Learning Pages

Worked Examples | Guided Labs | Case Studies | Mistake Clinic | Reading Guide | Capstone Thread