Master Git
The Interactive Way

Learn Git through interactive simulations, engaging quizzes, beautiful visualizations, and hands-on exercises. From basics to advanced workflows.

8
Interactive Lessons
50+
Git Commands
25
Quiz Questions
∞
Practice Possibilities
commit
branch
merge
🎮

Interactive Simulations

Practice Git commands in a safe, visual environment

📊

Visual Diagrams

Understand Git concepts with animated flowcharts

🎯

Interactive Quizzes

Test your knowledge with engaging quizzes

🏆

Earn Achievements

Unlock badges as you master Git concepts

🌱 Git Beginner
📝 First Commit
🌿 Branch Master
🔀 Merge Expert
🤝 Team Player
👑 Git Master

Git Basics

Understanding the fundamentals of version control

What is Git?

Essential

Git is a distributed version control system that tracks changes in your code over time. Created by Linus Torvalds in 2005, it's now the most widely used version control system in the world.

💡 Why Use Git?

Git acts like a time machine for your code. Every change you make is recorded, allowing you to travel back to any point in your project's history. It's essential for collaboration and prevents the chaos of "final_v2_FINAL_really_final.js" file naming.

✓ Track every change
✓ Collaborate with teams
✓ Revert mistakes easily
✓ Work on multiple features

Repository

Core Concept

A repository (or "repo") is a folder that contains your project files and a hidden .git folder that stores the complete history of all changes.

Working Directory
Your actual files that you edit
Staging Area (Index)
Changes ready to be committed
Repository (.git)
Permanent snapshots of your project
The staging area lets you choose exactly which changes to include in your next commit.

Essential Commands

Practice

These are the commands you'll use every day. Click any command to see it in action, or click the copy button to copy it to your clipboard.

git init

Initialize a new Git repository in the current folder. Creates the hidden .git directory.

git add .

Stage all changed files for the next commit. Use git add filename for specific files.

git commit -m "message"

Create a snapshot of staged changes with a descriptive message. Good messages explain why, not just what.

git status

Check which files have changed, which are staged, and which branch you're on.

git log --oneline

View commit history in a compact format. Add --graph to see branches visually.

git diff

Show line-by-line differences between your working directory and the last commit.

Git Workflow

Interactive

The basic Git workflow follows three stages: modify files → stage changes → commit. Try it yourself below!

📝

Working Directory

index.html
styles.css
git add →
📦

Staging Area

git commit →
💾

Repository

Initial commit

💡 Drag files to the staging area, then click the commit button that appears!

Branching & Merging

Master parallel development workflows

What are Branches?

Key Concept

Branches are independent lines of development. Think of them as parallel universes for your code where you can make changes without affecting the main project.

🌿 Why Branch?

Branches let you work on new features, fix bugs, or experiment freely. If something goes wrong, you can simply delete the branch. If it works, you merge it back!

C1 C2 C3 C4 main feature

Branch Commands

Essential

Master these commands to navigate between branches effortlessly:

git branch feature-name

Create a new branch (doesn't switch to it)

git checkout feature-name

Switch to an existing branch

git checkout -b feature-name

Create AND switch to new branch (most common)

git switch feature-name

Modern way to switch branches (Git 2.23+)

git branch -d feature-name

Delete a merged branch (-D to force delete)

Use descriptive branch names like feature/user-login or bugfix/header-alignment

Interactive Branch Simulator

Interactive

See how branches work in real-time! Create branches, add commits, and merge them back.

Current Branch: main

Total Commits: 3

Merge Strategies

Advanced

Fast-Forward Merge

Before main feature After main

Main branch simply moves forward to include feature branch commits.

Three-Way Merge

Creates merge commit merge

Creates a new commit that combines both branches.

Resolving Conflicts

Important

Conflicts occur when Git can't automatically merge changes. Here's how to resolve them:

Conflict in file.txt
<<<<<<< HEAD
This is the main branch version
=======
This is the feature branch version
>>>>>>> feature-branch
→
After resolution
This is the merged version
combining both changes
1️⃣ Edit the conflicted file
2️⃣ Remove conflict markers
3️⃣ Keep desired changes
4️⃣ git add the file
5️⃣ git commit to complete

Git Workflows

Learn popular collaboration strategies used by teams worldwide

🌊

Git Flow

Popular

A branching model designed for release management with distinct branches for features, releases, and hotfixes.

main Production
→
develop Integration
→
feature/* New features
1

Create feature branch

git checkout -b feature/login develop

2

Complete feature & merge

git checkout develop && git merge feature/login

3

Create release branch

git checkout -b release/1.0 develop

4

Merge to main & develop

git checkout main && git merge release/1.0

🐙

GitHub Flow

Simple

A lightweight, branch-based workflow perfect for continuous deployment and smaller teams.

main Always deployable
→
feature Short-lived
→
PR Review & Merge
1

Create branch from main

git checkout -b feature-name main

2

Commit changes regularly

git commit -m "Add feature"

3

Open Pull Request

git push origin feature-name

4

Merge after review

Merge PR via GitHub

🌳

Trunk-Based Development

Advanced

A source-control practice where developers merge small, frequent updates to a core "trunk" or main branch.

main/trunk Single branch
⟲
CI/CD Continuous
✓ Small, frequent commits
✓ Feature flags
✓ Strong CI/CD
✓ Code reviews
🍴

Forking Workflow

Open Source

Perfect for open source projects where contributors don't have direct access to the main repository.

1

Fork the repository

Create your own copy on GitHub

2

Clone your fork

git clone your-fork-url

3

Add upstream remote

git remote add upstream original-url

4

Submit Pull Request

From your fork to upstream

Advanced Git Techniques

Level up your Git skills with these powerful commands

Git Rebase

Advanced

Rebase rewrites commit history by moving your branch's commits to a new base point. This creates a cleaner, linear history.

🔄 Rebase vs Merge

While merge preserves history exactly as it happened, rebase creates a cleaner linear history. Use rebase for local cleanup, merge for shared branches.

Before Rebase
C1 C2 C3 C4
After Rebase
C1 C2 C3 C4'
git rebase main

Rebase current branch onto main

Never rebase commits that have been pushed to a shared repository!

Cherry Pick

Advanced

Cherry-pick lets you copy specific commits from one branch to another. Perfect for applying a hotfix to multiple branches.

🍒 When to Cherry Pick

Use when you need specific changes from another branch without merging everything. Common for backporting bug fixes to older versions.

Cherry pick
git cherry-pick abc123

Apply commit abc123 to current branch

Git Stash

Useful

Stash lets you temporarily save uncommitted changes and switch contexts. It's like a clipboard for your work in progress.

📦 When to Stash

Need to quickly switch branches but not ready to commit? Stash your changes, switch branches, do your work, then pop your stash when you're back!

stash@{0}: WIP on feature-login
stash@{1}: WIP on bugfix-header
stash@{2}: experimental changes
git stash

Save all uncommitted changes

git stash pop

Apply and remove most recent stash

git stash list

View all saved stashes

git stash apply

Apply stash but keep it in list

Tags & Releases

Important

Mark specific points in history as important (releases, versions).

v1.0.0 v2.0.0
git tag v1.0.0

Create a lightweight tag

git tag -a v1.0.0 -m "Release"

Create annotated tag

Reset vs Revert

Critical

Git Reset

Moves branch pointer back, removing commits from history.

HEAD Removed
git reset --hard HEAD~2

⚠️ Use with caution! Changes history.

Git Revert

Creates new commit that undoes changes, preserving history.

Revert
git revert abc123

✓ Safe for shared branches!

Working with Remotes

Essential

Local Repository

git push
↑
git pull
↓

Remote Repository

git remote add origin url

Add remote repository

git push origin main

Push changes to remote

git pull origin main

Fetch and merge changes

git fetch origin

Download without merging

git clone url

Copy remote repository

Git Simulator

Practice Git commands in a safe, interactive environment

Git Terminal Simulator
Welcome to Git Simulator! 🎮
Type 'help' to see available commands.
Type 'tutorial' for a guided walkthrough.
$ git

Repository State

Current Branch: main
Total Commits: 0
Branches: 1

Test Your Knowledge

Challenge yourself with interactive quizzes and earn achievements

Loading question...

🏆 Your Achievements

🎯 Quiz Starter - Complete 1 quiz
⚡ Quick Learner - Score 70%+
🌟 Git Pro - Score 90%+
💯 Perfect Score - 100%
🔄 Persistent - Complete 3 quizzes
👑 Git Master - All achievements

Git Cheat Sheet

Quick reference for common Git commands

📋 Setup & Config

git config --global user.name "Name"

Set your name

git config --global user.email "email"

Set your email

git init

Initialize repository

git clone <url>

Clone repository

💾 Basic Snapshotting

git status

Check status

git add .

Stage all changes

git commit -m "message"

Commit staged changes

git commit -am "message"

Stage and commit

git diff

Show unstaged changes

git diff --staged

Show staged changes

🌿 Branching & Merging

git branch

List branches

git branch <name>

Create branch

git checkout <branch>

Switch branch

git checkout -b <branch>

Create and switch

git merge <branch>

Merge branch

git branch -d <branch>

Delete branch

🔄 Sharing & Updating

git remote add origin <url>

Add remote

git push origin <branch>

Push to remote

git pull

Fetch and merge

git fetch

Download changes

📜 Inspection & Comparison

git log

View commit history

git log --oneline

Compact history

git log --graph

Visual history

git show <commit>

Show commit details

⏪ Undo Changes

git reset HEAD <file>

Unstage file

git checkout -- <file>

Discard changes

git revert <commit>

Revert commit

git reset --hard HEAD~1

Undo last commit

🎯 Advanced

git stash

Save changes temporarily

git stash pop

Restore stashed changes

git rebase <branch>

Rebase onto branch

git cherry-pick <commit>

Apply specific commit

git tag <name>

Create tag

💡 Pro Tips

Commit Often

Make small, frequent commits with clear messages. It's easier to understand and revert if needed.

Branch for Features

Create a new branch for each feature or bug fix. Keep main branch stable.

Pull Before Push

Always pull latest changes before pushing to avoid conflicts.

Write Good Messages

Use present tense, be specific: "Add login feature" not "Added stuff".

Use .gitignore

Ignore build files, dependencies, and sensitive data. Never commit secrets!

Review Before Commit

Use git diff to review changes before committing. Catch mistakes early.