Master Git
The Interactive Way
Learn Git through interactive simulations, engaging quizzes, beautiful visualizations, and hands-on exercises. From basics to advanced workflows.
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 Basics
Understanding the fundamentals of version control
What is Git?
EssentialGit 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.
Repository
Core ConceptA repository (or "repo") is a folder that contains your project files and a hidden .git folder that stores the complete history of all changes.
Essential Commands
PracticeThese 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
InteractiveThe basic Git workflow follows three stages: modify files → stage changes → commit. Try it yourself below!
Working Directory
Staging Area
Repository
💡 Drag files to the staging area, then click the commit button that appears!
Branching & Merging
Master parallel development workflows
What are Branches?
Key ConceptBranches 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!
Branch Commands
EssentialMaster 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)
feature/user-login or bugfix/header-alignmentInteractive Branch Simulator
InteractiveSee how branches work in real-time! Create branches, add commits, and merge them back.
Current Branch: main
Total Commits: 3
Merge Strategies
AdvancedFast-Forward Merge
Main branch simply moves forward to include feature branch commits.
Three-Way Merge
Creates a new commit that combines both branches.
Resolving Conflicts
ImportantConflicts occur when Git can't automatically merge changes. Here's how to resolve them:
<<<<<<< HEAD
This is the main branch version
=======
This is the feature branch version
>>>>>>> feature-branch
This is the merged version
combining both changes
git add the filegit commit to completeGit Workflows
Learn popular collaboration strategies used by teams worldwide
Git Flow
PopularA branching model designed for release management with distinct branches for features, releases, and hotfixes.
Create feature branch
git checkout -b feature/login develop
Complete feature & merge
git checkout develop && git merge feature/login
Create release branch
git checkout -b release/1.0 develop
Merge to main & develop
git checkout main && git merge release/1.0
GitHub Flow
SimpleA lightweight, branch-based workflow perfect for continuous deployment and smaller teams.
Create branch from main
git checkout -b feature-name main
Commit changes regularly
git commit -m "Add feature"
Open Pull Request
git push origin feature-name
Merge after review
Merge PR via GitHub
Trunk-Based Development
AdvancedA source-control practice where developers merge small, frequent updates to a core "trunk" or main branch.
Forking Workflow
Open SourcePerfect for open source projects where contributors don't have direct access to the main repository.
Fork the repository
Create your own copy on GitHub
Clone your fork
git clone your-fork-url
Add upstream remote
git remote add upstream original-url
Submit Pull Request
From your fork to upstream
Advanced Git Techniques
Level up your Git skills with these powerful commands
Git Rebase
AdvancedRebase 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
After Rebase
git rebase main
Rebase current branch onto main
Cherry Pick
AdvancedCherry-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.
git cherry-pick abc123
Apply commit abc123 to current branch
Git Stash
UsefulStash 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!
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
ImportantMark specific points in history as important (releases, versions).
git tag v1.0.0
Create a lightweight tag
git tag -a v1.0.0 -m "Release"
Create annotated tag
Reset vs Revert
CriticalGit Reset
Moves branch pointer back, removing commits from history.
git reset --hard HEAD~2
⚠️ Use with caution! Changes history.
Git Revert
Creates new commit that undoes changes, preserving history.
git revert abc123
✓ Safe for shared branches!
Working with Remotes
EssentialLocal Repository
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
Repository State
Test Your Knowledge
Challenge yourself with interactive quizzes and earn achievements
Loading question...
🏆 Your 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.