# Git Workshop A comprehensive, hands-on Git workshop with 13 progressive modules covering everything from basic commits to advanced debugging techniques. Each module presents a real-world scenario that you must solve using Git commands, with automated verification to confirm your solution. Perfect for developers who want to move beyond basic Git usage and master professional workflows including rebasing, conflict resolution, bisecting, worktrees, and more. ## Workshop Structure Each module is a self-contained challenge that teaches specific git concepts: ### Beginner Level - **Module 01**: Git Basics - Initialize repositories, stage changes, make commits - **Module 02**: Viewing History - Use git log and git diff to explore project history - **Module 03**: Branching Basics - Create, switch, and manage branches ### Intermediate Level - **Module 04**: Merging - Combine branches with fast-forward and three-way merges - **Module 05**: Merge Conflicts - Identify, understand, and resolve merge conflicts - **Module 06**: Rebasing - Rebase branches to create linear history - **Module 07**: Interactive Rebase - Clean up commit history with reset and recommit - **Module 08**: Cherry-Pick - Apply specific commits from one branch to another ### Advanced Level - **Module 09**: Reset vs Revert - Understand when to rewrite history vs create new commits - **Module 10**: Stash - Temporarily save work without committing - **Module 11**: Working with Remotes - Clone, push, pull, and fetch from remote repositories - **Module 12**: Worktrees - Work on multiple branches simultaneously - **Module 13**: Bisect - Use binary search to find bugs in commit history ## How to Use This Workshop 1. Navigate to a module directory (e.g., `module-01-basics`) 2. Read the `README.md` to understand the challenge 3. Run `./setup.ps1` to create the challenge environment 4. Complete the challenge using git commands 5. Run `./verify.ps1` to check if you've solved it correctly 6. Move to the next module **Quick Reference**: See [GIT-CHEATSHEET.md](GIT-CHEATSHEET.md) for a comprehensive list of all Git commands covered in this workshop. Don't worry about memorizing everything - use this as a reference when you need to look up command syntax! ## Running PowerShell Scripts Each module includes setup, verification, and reset scripts. Here's how to run them: ### Windows If you encounter an "execution policy" error when running scripts, open PowerShell as Administrator and run: ```powershell Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser ``` Then run scripts using: ```powershell .\setup.ps1 ``` ### macOS/Linux First, make sure scripts are executable (only needed once): ```bash chmod +x module-*/setup.ps1 module-*/verify.ps1 module-*/reset.ps1 ``` Then run scripts using: ```bash ./setup.ps1 ``` Or explicitly with PowerShell: ```bash pwsh setup.ps1 ``` **Note:** All examples in this workshop use Windows syntax (`.\script.ps1`). macOS/Linux users should use `./script.ps1` instead. ## Requirements ### Git You need Git version 2.23 or later (for `git switch` and `git restore` commands). **Check if Git is installed:** ```powershell git --version ``` If you see a version number (e.g., "git version 2.34.1"), you're all set! If not, download and install from: https://git-scm.com/downloads **Configure Git (Required - First Time Only):** Before making your first commit, tell Git who you are: ```powershell git config --global user.name "Your Name" git config --global user.email "your.email@example.com" ``` **Verify your configuration:** ```powershell git config --global user.name git config --global user.email ``` You should see your name and email printed. This is required to make commits in Git. ### PowerShell - **Windows**: PowerShell 5.1+ (already included in Windows 10/11) - **macOS/Linux**: Install PowerShell Core 7+ from https://github.com/PowerShell/PowerShell **Check PowerShell version:** ```powershell $PSVersionTable.PSVersion ``` ### Basic Command Line Knowledge You should know how to: - Navigate directories (`cd`, `ls` or `dir`) - See your current location (`pwd`) - Read text files (`cat` or `type`) Don't worry if you're not an expert - we'll guide you through each step! ## Optional: Install Glow for Pretty Markdown This workshop includes many markdown files with instructions. You can install `glow` to render them beautifully in your terminal: ```powershell .\install-glow.ps1 ``` After installation, read markdown files with: ```powershell # Windows .\bin\glow.exe README.md # macOS/Linux ./bin/glow README.md ``` **Pro tip**: Use `glow -p` for pager mode on longer files! Without glow, you can still read markdown files with any text editor or `cat README.md`. ## Common Git Terms New to Git? Here are the key terms you'll encounter: - **Repository (or "repo")**: A project folder tracked by Git, containing your files and their complete history - **Commit**: A snapshot of your project at a specific point in time (like a save point in a video game) - **Staging Area (or "Index")**: A preparation area where you select which changes to include in your next commit - **Working Directory**: The actual files you see and edit on your computer - **Branch**: An independent line of development (like a parallel universe for your code) - **HEAD**: A pointer showing which commit you're currently working from - **main/master**: The primary branch in a repository (main is the modern convention) - **Merge**: Combining changes from different branches - **Remote**: A version of your repository hosted elsewhere (like GitHub) Don't worry if these don't make sense yet - you'll learn them hands-on as you progress! ## Getting Started Start with Module 01: ```powershell cd module-01-basics .\setup.ps1 ``` Follow the instructions in each module's README.md file. ## What Makes This Workshop Different - **Hands-On Practice**: Each module creates a real Git scenario you must solve - **Automated Verification**: Scripts check your solution instantly - **Progressive Difficulty**: Builds from basics to advanced Git techniques - **Reset Anytime**: Each module includes a reset script for a fresh start - **Self-Paced**: Learn at your own speed with detailed README guides - **No Internet Required**: All modules work offline with local repositories ## Learning Path The modules are designed to build on each other: 1. **Start Here** (Modules 1-3): Core Git fundamentals everyone needs 2. **Collaboration** (Modules 4-5): Working with branches and resolving conflicts 3. **History Management** (Modules 6-8): Rewriting and organizing commits 4. **Advanced Workflows** (Modules 9-11): Professional Git techniques 5. **Power User** (Modules 12-13): Advanced tools for productivity and debugging ## Tips for Success - Don't skip modules - each builds on previous concepts - Read the README.md thoroughly before starting each challenge - Keep [GIT-CHEATSHEET.md](GIT-CHEATSHEET.md) open as a quick reference - Experiment freely - you can always run `./reset.ps1` to start over - Use `git log --oneline --graph --all` frequently to visualize repository state - If stuck, check the Key Concepts section in the module's README - Consider installing glow for better markdown reading experience ## Skills You'll Master By completing this workshop, you'll be able to: - ✅ Create and manage Git repositories with confidence - ✅ Navigate project history and understand what changed when - ✅ Use branches effectively for parallel development - ✅ Merge branches and resolve conflicts like a pro - ✅ Rebase to maintain clean, linear history - ✅ Clean up messy commits before submitting pull requests - ✅ Cherry-pick specific commits across branches - ✅ Choose correctly between reset and revert - ✅ Use stash to manage work-in-progress without commits - ✅ Collaborate effectively with remote repositories - ✅ Work on multiple branches simultaneously with worktrees - ✅ Debug efficiently by finding bug-introducing commits with bisect These are professional-level Git skills used daily by developers at top tech companies. ## For Workshop Facilitators Before distributing this workshop to attendees: 1. **Delete the root `.git` directory**: This prevents confusion and ensures attendees practice git from scratch ```powershell Remove-Item -Path .git -Recurse -Force ``` 2. Each module's `challenge/` directory will become its own independent git repository when attendees run `setup.ps1` 3. This isolation ensures each module provides a clean learning environment