Skip to main content
The Introduction Sequence is your starting point for learning Git. This sequence covers the fundamental Git commands and concepts that form the foundation for all other Git operations.

Overview

This sequence provides a gentle, well-paced introduction to Git’s core functionality. By the end, you’ll understand how to make commits, create and manage branches, and combine work using merging and rebasing.

Levels in This Sequence

The Introduction Sequence consists of four progressive levels:

1. Introduction to Git Commits

What you’ll learn: The fundamental unit of Git - the commit. Key concepts:
  • A commit records a snapshot of all tracked files in your directory
  • Git compresses commits as deltas (changes) rather than copying entire directories
  • Commits maintain a history of when changes were made
  • Each commit has parent commits, creating a commit tree
Goal: Create two commits to see how the commit tree grows. Commands introduced:
git commit
Commits are lightweight and switching between them is fast. Think of them as snapshots of your project at a point in time.

2. Branching in Git

What you’ll learn: How to create and switch between branches. Key concepts:
  • Branches are lightweight pointers to specific commits
  • Creating branches has no storage overhead
  • The mantra: “branch early, and branch often”
  • Branches help you divide work logically
  • HEAD indicates which branch you’re currently on (shown with an asterisk)
Goal: Create a new branch called bugFix and switch to it. Commands introduced:
git branch <branch-name>    # Create a new branch
git checkout <branch-name>  # Switch to a branch
git checkout -b <name>      # Create and switch in one command
Git 2.23 introduced git switch as an alternative to git checkout, but this tutorial uses checkout as it’s more widely used.

3. Merging in Git

What you’ll learn: How to combine work from different branches using merge. Key concepts:
  • git merge combines work from two branches
  • A merge creates a special commit with two parent commits
  • After merging, the target branch contains all work from both branches
  • Merge commits help preserve the full history of parallel development
Goal: Create two branches with different commits, then merge them back together. Commands introduced:
git merge <branch-name>
Example scenario:
git checkout -b bugFix
git commit
git checkout main
git commit
git merge bugFix  # Merge bugFix into main
After merging, you may want to merge the other way too (fast-forward) to ensure both branches point to the same commit.

4. Rebase Introduction

What you’ll learn: How to create a linear commit history using rebase. Key concepts:
  • git rebase takes commits and “copies” them to a new location
  • Rebasing creates a cleaner, more linear commit history
  • The original commits still exist (shown faded), while new copies are created
  • Rebase makes it look like features were developed sequentially, even when they were parallel
Goal: Use rebase to move your feature branch onto main, creating a linear history. Commands introduced:
git rebase <branch-name>
Example scenario:
git checkout -b bugFix
git commit
git checkout main
git commit
git checkout bugFix
git rebase main  # Move bugFix commits on top of main
Rebase creates new commit copies. The original commits (like C3) still exist but are no longer on the main line of development.

Merge vs Rebase

Both merge and rebase combine work from different branches, but they do it differently:
AspectMergeRebase
HistoryPreserves exact history with merge commitsCreates linear history
CommitsCreates new merge commitCopies commits to new location
Use caseWhen you want to preserve full historyWhen you want clean, linear history
CollaborationSafer for shared branchesBest for local branches

What’s Next?

After completing the Introduction Sequence, you’ll be ready for:
  • Ramping Up: Learn about relative refs, detached HEAD, cherry-pick, and interactive rebase
  • Moving Work Around: Master techniques for precisely moving commits
  • Remote Repositories: Start collaborating with others using git remotes

Start Learning

Begin the Introduction Sequence in the interactive tutorial

Build docs developers (and LLMs) love