11 Commits

Author SHA1 Message Date
Bjarke Sporring
a898030a9f fix: use git stash push instead of git stash save which is deprecated 2026-01-18 09:27:12 +01:00
Bjarke Sporring
382a125076 fix: add install instructions 2026-01-16 12:43:11 +01:00
Bjarke Sporring
d80fa74af9 refactor: move the installation description to the README.md 2026-01-16 12:40:49 +01:00
Bjarke Sporring
7fc0c1342a refactor: cleanup root readme 2026-01-16 12:36:40 +01:00
Bjarke Sporring
cba2d9bb16 chore: cleanup 2026-01-16 12:15:11 +01:00
Bjarke Sporring
968a44f9a5 fix: cleanup some explanations 2026-01-16 12:11:03 +01:00
Bjarke Sporring
c39573573f fix: remove mention of rebase 2026-01-16 11:13:11 +01:00
Bjarke Sporring
ee67433fdd refactor: minor cleanup and expanding explanations for multiplayer 2026-01-16 11:12:53 +01:00
Bjarke Sporring
100e89b23d refactor: update docs for the install.ps1 script 2026-01-16 10:26:02 +01:00
b58080b8e8 Merge pull request 'refactor-reset-revert' (#3) from refactor-reset-revert into main
Reviewed-on: #3
2026-01-16 09:19:41 +00:00
2240cbe10d Merge pull request 'refactor-reset-revert' (#1) from refactor-reset-revert into main
Reviewed-on: #1
2026-01-15 16:32:19 +00:00
9 changed files with 206 additions and 763 deletions

View File

@@ -4,7 +4,7 @@
By the end of this module, you will:
- Understand what cherry-picking is and how it works
- Know when to use cherry-pick vs merge or rebase
- Know when to use cherry-pick vs merge
- Apply specific commits from one branch to another
- Understand common use cases for cherry-picking
- Learn how cherry-pick creates new commits with different hashes

View File

@@ -101,7 +101,7 @@ Suddenly, your teammate reports a **critical security bug** in production! You n
3. **Stash your work with a message:**
```pwsh
git stash save "WIP: login feature"
git stash push -m "WIP: login feature"
```
4. **Verify working directory is clean:**
@@ -166,7 +166,7 @@ Suddenly, your teammate reports a **critical security bug** in production! You n
```pwsh
# Stash current changes with a message
git stash save "description"
git stash push -m "description"
# Stash without a message (not recommended)
git stash
@@ -273,7 +273,7 @@ The verification will check that:
**Solution:**
```pwsh
# Stash your changes first
git stash save "work in progress"
git stash push -m "work in progress"
# Now you can switch
git switch other-branch
@@ -321,7 +321,7 @@ git stash show -p stash@{0}
## Tips for Success
💡 **Always add a message** - `git stash save "your message"` helps you remember what you stashed
💡 **Always add a message** - `git stash push -m "your message"` helps you remember what you stashed
💡 **Use pop, not apply** - Pop removes the stash automatically, keeping your stash list clean
💡 **Stash before pulling** - Avoid merge conflicts when pulling updates
💡 **Preview before applying** - Use `git stash show -p` to see what's in a stash
@@ -333,7 +333,7 @@ git stash show -p stash@{0}
### Quick Branch Switch
```pwsh
# You're working on feature-A
git stash save "feature A progress"
git stash push -m "feature A progress"
git switch hotfix-branch
# Fix the issue, commit
git switch feature-A
@@ -343,7 +343,7 @@ git stash pop
### Pull with Local Changes
```pwsh
# You have uncommitted changes
git stash save "local changes"
git stash push -m "local changes"
git pull
git stash pop
# Resolve conflicts if any
@@ -352,7 +352,7 @@ git stash pop
### Test Clean State
```pwsh
# Stash changes to test on clean code
git stash save "testing clean state"
git stash push -m "testing clean state"
# Run tests
git stash pop # Restore your changes
```

View File

@@ -34,7 +34,7 @@ Participants need:
---
## Pre-Workshop Setup
## Setup
### Step 1: Add User Accounts
@@ -131,15 +131,6 @@ git add numbers.txt
git commit -m "feat: add shuffled numbers for challenge"
git push
```
### Step 4: Verify Student Access
Students added to the project automatically have access. Verify:
1. Go to **Project Settings****Repositories****number-challenge**
2. Click **Security** tab
3. Verify project team has **Contribute** permission
---
## During the Workshop
@@ -153,12 +144,12 @@ Students added to the project automatically have access. Verify:
### The Exercise Flow
1. **Students pull** the latest changes
2. **One person** moves a number to its correct position
2. **One person** creates a branch, moves a number to its correct position
3. **They commit and push**
4. **Others pull** and see the change
5. **Repeat** until sorted
### Creating Conflicts (The Learning Moment)
### Same branch conflicts
Conflicts happen naturally when multiple people edit at once. You can encourage this:
@@ -166,13 +157,6 @@ Conflicts happen naturally when multiple people edit at once. You can encourage
- Watch them experience the push rejection
- Guide them through pulling and resolving the conflict
### Monitoring Progress
Check progress in Azure DevOps:
- **Repos → Commits**: See who's contributing
- **Repos → Files → numbers.txt**: See current state
### Common Issues
**"I can't push!"**

View File

@@ -20,15 +20,15 @@ SSH (Secure Shell) keys provide a secure way to authenticate with Azure DevOps w
Before starting, ensure you have:
- **Git 2.23 or higher** installed
```powershell
```pwsh
git --version
```
- **Azure DevOps account** with access to your organization/project
- If you don't have one, create a free account at [dev.azure.com](https://dev.azure.com)
- If you don't ask your organisation for an invitation
- **PowerShell 7+ or Bash terminal** for running commands
```powershell
```pwsh
pwsh --version
```
@@ -42,18 +42,18 @@ SSH authentication uses a key pair: a private key (stays on your computer) and a
Open your terminal and run:
```powershell
```pwsh
ssh-keygen -t rsa
```
**Note about RSA:** Azure DevOps currently only supports RSA SSH keys. While newer algorithms like Ed25519 offer better security and performance, they are not yet supported by Azure DevOps. See the note at the end of this guide for more information.
**Note about RSA:** Azure DevOps currently only supports RSA SSH keys. While newer algorithms like Ed25519 offer better security and performance, they are not yet supported by Azure DevOps.
### Save Location
When prompted for the file location, press `Enter` to accept the default:
```
Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):
Enter file in which to save the key (C:\Users\YourName\.ssh\id_rsa):
```
**Default locations:**
@@ -73,7 +73,7 @@ Enter same passphrase again:
Check that your keys were created:
**Windows PowerShell:**
```powershell
```pwsh
dir $HOME\.ssh\
```
@@ -108,27 +108,17 @@ Now you'll upload your public key to Azure DevOps.
Open your terminal and display your public key:
**Linux/Mac:**
```bash
cat ~/.ssh/id_rsa.pub
```
**Windows PowerShell:**
```powershell
```pwsh
type $HOME\.ssh\id_rsa.pub
```
**Windows Command Prompt:**
```cmd
type %USERPROFILE%\.ssh\id_rsa.pub
```
The output will look like this:
```
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC2YbXnrSK5TTflZSwUv9KUedvI4p3JJ4dHgwp/SeJGqMNWnOMDbzQQzYT7E39w9Q8ItrdWsK4vRLGY2B1rQ+BpS6nn4KhTanMXLTaUFDlg6I1Yn5S3cTTe8dMAoa14j3CZfoSoRRgK8E+ktNb0o0nBMuZJlLkgEtPIz28fwU1vcHoSK7jFp5KL0pjf37RYZeHkbpI7hdCG2qHtdrC35gzdirYPJOekErF5VFRrLZaIRSSsX0V4XzwY2k1hxM037o/h6qcTLWfi5ugbyrdscL8BmhdGNH4Giwqd1k3MwSyiswRuAuclYv27oKnFVBRT+n649px4g3Vqa8dh014wM2HDjMGENIkHx0hcV9BWdfBfTSCJengmosGW+wQfmaNUo4WpAbwZD73ALNsoLg5Yl1tB6ZZ5mHwLRY3LG2BbQZMZRCELUyvbh8ZsRksNN/2zcS44RIQdObV8/4hcLse30+NQ7GRaMnJeAMRz4Rpzbb02y3w0wNQFp/evj1nN4WTz6l8= your@email.com
```
**Copy the entire output** (from `ssh-rsa` to your email address).
**Copy the entire output** (from `ssh-rsa` to and including your email address).
### Paste and Name Your Key
@@ -152,12 +142,12 @@ Now that SSH is configured, you can use it for all Git operations.
To clone a repository using SSH:
```bash
```pwsh
git clone git@ssh.dev.azure.com:v3/{organization}/{project}/{repository}
```
**Example** (replace placeholders with your actual values):
```bash
```pwsh
git clone git@ssh.dev.azure.com:v3/myorg/git-workshop/great-print-project
```
@@ -175,7 +165,7 @@ git clone git@ssh.dev.azure.com:v3/myorg/git-workshop/great-print-project
All standard Git commands now work seamlessly with SSH:
```bash
```pwsh
# Pull latest changes
git pull
@@ -195,7 +185,6 @@ git push -u origin feature-branch
## Additional Resources
- **Azure DevOps SSH Documentation**: [https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate](https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate)
- **SSH Key Best Practices**: [https://security.stackexchange.com/questions/tagged/ssh-keys](https://security.stackexchange.com/questions/tagged/ssh-keys)
- **Git with SSH**: [https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key](https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key)
---
@@ -204,17 +193,14 @@ git push -u origin feature-branch
### Common Commands
```bash
```pwsh
# Generate RSA key
ssh-keygen -t
# Display public key (Linux/Mac)
cat ~/.ssh/id_rsa.pub
# Display public key (Windows)
# Display public key
type $HOME\.ssh\id_rsa.pub
# Clone with SSH
# Clone with SSH. You can find this url on Azure DevOps
git clone git@ssh.dev.azure.com:v3/{org}/{project}/{repo}
# Check remote URL

View File

@@ -12,7 +12,6 @@ Learn to collaborate on a shared repository using:
```
1. Create branch → 2. Make changes → 3. Push branch
6. Delete branch ← 5. Merge PR ← 4. Create PR
```
@@ -110,9 +109,15 @@ git pull
1. Both people should create a branch with changes to `feature-1` and `feature-2`, you task is to change the position of number 5. Where you place it is up to you.
2. Now both people should push their respective branch `git push <the-branch>`
3. Now merge `feature-1` branch first, going throught the Pull Request flow.
1. Person A pushes their branch `git push feature-1`
2. Person B pushes their branch `git push feature-2`
3. Now merge `feature-1` branch first, going throught the Pull Request flow (see Step 5).
4. Then merge `feature-2` branch second, and notice you'll get a MERGE CONFLICT.
5. It is not the owner of `feature-2` branch to resolve the conflict. This is done by merge the `main` branch into `feature-2` locally and so the owner of `feature-2` has to do the following
5. The owner of `feature-2` (Person B) is now tasked with resolving the conflict.
In order to solve merge conflicts through a Shared Server (Azure DevOps) you have to do merges in <q>reverse</q>, meaning: Instead of, like in module <q>03-branching-and-merging</q>, merging the feature-branch into the `main` branch, we merge the `main` branch into the feature branch.
Doing so ensures that the `main` branch maintains the integrity it's supposed to have and the conflicts are solved on the feature-branch side before being merged into the `main` branch. The idea here being that, we ONLY modify the main branch through merges facilitated (and reviewed) by Pull Requests. We want the `main` branch to be as stable as possible.
```pwsh
# First get the latest changes on main
git switch main
@@ -123,7 +128,8 @@ git pull
# Now we resolve the merge. We're merging the main branch INTO the feature-2 branch.
git merge main
# Resolve the merge conflict in numbers.txt
# Resolve the merge conflict in numbers.txt by opening in VSCode and choosing the changes you want.
# How you solve it is up to you.
# Once resolved
git add numbers.txt
git commit
@@ -137,30 +143,29 @@ git pull
| Command | What It Does |
|---------|--------------|
| `git switch -c <name>` | Create and switch to new branch |
| `git push -u origin <branch>` | Push branch to Azure DevOps |
| `git switch main` | Switch to main branch |
| `git switch -c <branch-name>` | Create and switch to new branch |
| `git switch <branch-name>` | Switch to branch |
| `git push` | Push branch to Azure DevOps |
| `git pull` | Get latest changes from remote |
---
## Common Issues
## Cheatsheet
### "My PR has conflicts"
1. Update your branch with latest main:
```powershell
### Solving merge conflicts
```pwsh
git switch main
git pull
git switch <branch-name>
git merge main
# ... Solve the conflicts
git push
```
2. Resolve conflicts in VS Code
3. Commit and push again
### "I need to make more changes to my PR"
Just commit and push to the same branch - the PR updates automatically:
```powershell
```pwsh
git add .
git commit -m "fix: address review feedback"
git push

View File

@@ -287,7 +287,7 @@ git stash
Save your uncommitted changes temporarily and revert to a clean working directory.
```bash
git stash save "description"
git stash push -m "<description>"
```
Stash changes with a descriptive message.

View File

@@ -1,337 +0,0 @@
# Installation Guide for Windows 11
This guide will help you install everything needed for the Git Workshop on Windows 11.
## Quick Start (Automated Installation)
**Easiest option:** Run our oneshot installation script that installs all prerequisites and clones the repository automatically.
```powershell
irm https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | iex
```
This will:
- Install PowerShell 7, Git 2.23+, and Visual Studio Code
- Clone the git-workshop repository to `~/git-workshop`
- Leave you ready to start the workshop immediately
**Alternative:** If you've already cloned the repository, you can run the local installation script:
1. Open **PowerShell** or **Windows Terminal**
2. Navigate to the git-workshop directory
3. Run the installation script:
```powershell
.\install-prerequisites.ps1
```
The script will:
- Check if tools are already installed
- Install PowerShell 7, Git 2.23+, and Visual Studio Code
- Prompt you for optional tools (Python 3.12, Windows Terminal)
- Show clear progress and verify each installation
- Display Git configuration instructions when complete
**If you prefer manual installation**, continue with the detailed steps below.
---
## Prerequisites
You'll need administrator access to install software on your Windows 11 machine.
## What You'll Install
1. **PowerShell 7** - Modern cross-platform PowerShell (replaces the older Windows PowerShell 5.1)
2. **Git** - Version control system (2.23 or later)
3. **Visual Studio Code** - Modern code editor with excellent Git integration
## Manual Installation Steps
### 1. Install PowerShell 7
PowerShell 7 is the modern, cross-platform version of PowerShell. Windows 11 comes with PowerShell 5.1, but we recommend PowerShell 7 for the best experience.
**Option A: Using winget (Recommended)**
Open **Windows Terminal** or **Command Prompt** and run:
```powershell
winget install --id Microsoft.PowerShell --source winget
```
**Option B: Manual Download**
1. Visit https://github.com/PowerShell/PowerShell/releases/latest
2. Download the file ending in `-win-x64.msi` (e.g., `PowerShell-7.4.1-win-x64.msi`)
3. Run the installer
4. Accept all defaults
**Verify Installation:**
Open a new terminal and run:
```powershell
pwsh --version
```
You should see version 7.x.x or higher.
**Important:** After installing PowerShell 7, use it instead of the older "Windows PowerShell 5.1". Look for "PowerShell 7" in your Start menu or Windows Terminal.
### 2. Install Git
Git is the version control system you'll learn in this workshop. You need version 2.23 or later.
**Option A: Using winget (Recommended)**
```powershell
winget install --id Git.Git -e --source winget
```
**Option B: Manual Download**
1. Visit https://git-scm.com/downloads
2. Click "Windows"
3. Download the 64-bit installer
4. Run the installer with these recommended settings:
- **Default editor**: Choose "Visual Studio Code" (we'll install it next)
- **PATH environment**: Select "Git from the command line and also from 3rd-party software"
- **Line ending conversions**: Choose "Checkout Windows-style, commit Unix-style line endings"
- **Terminal emulator**: Choose "Use Windows' default console window"
- All other settings: Accept defaults
**Verify Installation:**
Open a **new** PowerShell window and run:
```powershell
git --version
```
You should see version 2.23 or higher (e.g., `git version 2.43.0`).
### 3. Install Visual Studio Code
VS Code is a free, powerful code editor with excellent Git integration.
**Option A: Using winget (Recommended)**
```powershell
winget install --id Microsoft.VisualStudioCode --source winget
```
**Option B: Manual Download**
1. Visit https://code.visualstudio.com/
2. Click "Download for Windows"
3. Run the installer
4. During installation, check these options:
- ✅ Add "Open with Code" action to Windows Explorer file context menu
- ✅ Add "Open with Code" action to Windows Explorer directory context menu
- ✅ Register Code as an editor for supported file types
- ✅ Add to PATH
**Verify Installation:**
```powershell
code --version
```
You should see version information.
**Recommended VS Code Extensions:**
Open VS Code and install these extensions for the best Git experience:
1. **GitLens** - Supercharge Git capabilities
- Press `Ctrl+Shift+X` to open Extensions
- Search for "GitLens"
- Click Install
2. **Git Graph** - View Git history visually
- Search for "Git Graph"
- Click Install
3. **PowerShell** - Better PowerShell support
- Search for "PowerShell"
- Install the one from Microsoft
## Configure Git
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.
**Optional: Set VS Code as Git's Default Editor**
If you installed Git before VS Code, configure Git to use VS Code:
```powershell
git config --global core.editor "code --wait"
```
## PowerShell Execution Policy
When running PowerShell scripts (`.ps1` files) in this workshop, you might encounter an error about execution policies.
**If you see an error like "script cannot be loaded because running scripts is disabled":**
Open **PowerShell 7 as Administrator** and run:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
This allows you to run local scripts while maintaining security for downloaded scripts.
## Running Scripts in the Workshop
After installation, you can run workshop scripts using:
```powershell
.\setup.ps1
.\verify.ps1
.\reset.ps1
```
**Example workflow:**
```powershell
# Navigate to a module
cd 01-essentials\01-basics
# Run the setup script
.\setup.ps1
# Complete the challenge using Git commands
# ...
# Verify your solution
.\verify.ps1
```
## Optional: Python (for Module 08 only)
Module 08 (Multiplayer Git) uses Python for "The Great Print Project". You only need this for that specific module.
**Install Python 3.12:**
```powershell
winget install --id Python.Python.3.12 --source winget
```
**Verify installation:**
```powershell
python --version
```
You should see Python 3.12.x or higher.
## Optional: Windows Terminal (Highly Recommended)
Windows Terminal provides a modern terminal experience with tabs, better colors, and PowerShell 7 integration.
**Install:**
```powershell
winget install --id Microsoft.WindowsTerminal --source winget
```
Or install from the **Microsoft Store** (search for "Windows Terminal").
**After installation:**
- Press `Win+X` and select "Windows Terminal"
- Or search "Terminal" in the Start menu
- PowerShell 7 should be the default profile
## Verify Complete Installation
Run these commands to verify everything is installed correctly:
```powershell
# PowerShell version (should be 7.x.x)
pwsh --version
# Git version (should be 2.23 or higher)
git --version
# VS Code version
code --version
# Git configuration
git config --global user.name
git config --global user.email
# Optional: Python (for Module 08)
python --version
```
## Troubleshooting
### Git command not found
If `git --version` doesn't work after installation:
1. Close and reopen your terminal (Git needs a new terminal to update PATH)
2. Restart your computer if the problem persists
### VS Code command not found
If `code --version` doesn't work:
1. Ensure you checked "Add to PATH" during installation
2. Close and reopen your terminal
3. If still not working, reinstall VS Code with the PATH option enabled
### PowerShell execution policy errors
If you can't run `.ps1` scripts:
1. Open PowerShell 7 **as Administrator**
2. Run: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`
3. Close admin PowerShell and try again in a regular PowerShell window
### winget command not found
If `winget` doesn't work:
1. Update Windows 11 to the latest version (Settings → Windows Update)
2. Install "App Installer" from the Microsoft Store
3. Restart your computer
## You're Ready!
Once all verification commands work, you're ready to start the workshop!
```powershell
# Clone or download the git-workshop repository
# Navigate to it
cd path\to\git-workshop
# Start with Module 01
cd 01-essentials\01-basics
# Read the instructions
code README.md
# Run setup and begin!
.\setup.ps1
```
## Next Steps
- Read the main [README.md](README.md) for workshop overview
- Check [GIT-CHEATSHEET.md](GIT-CHEATSHEET.md) for Git command reference
- Start with Module 01: `01-essentials\01-basics`
Happy learning!

443
README.md
View File

@@ -1,40 +1,27 @@
# Git Workshop
A comprehensive, hands-on Git workshop with 15 progressive modules covering everything from basic commits to advanced debugging techniques and real-world collaboration. Each module presents a real-world scenario that you must solve using Git commands, with automated verification to confirm your solution.
A hands-on Git workshop with 8 progressive modules covering essential Git skills from basic commits to real-world collaboration. Each module presents a practical scenario 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, collaboration, and advanced Git techniques.
Perfect for developers who want to master Git fundamentals and professional workflows including branching, conflict resolution, and team collaboration.
## Workshop Structure
The workshop is organized into two tracks:
### 01 Essentials - Core Git Skills (8 modules)
### Essentials - Core Git Skills (8 modules)
Master fundamental Git concepts and collaborative workflows:
- **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 and Merging** - Create branches, merge them, and resolve conflicts (checkpoint-based)
- **Module 04: Cherry-Pick** - Apply specific commits from one branch to another
- **Module 05: Git Revert** - Safe undoing - preserve history while reversing changes (includes merge commit reversion)
- **Module 06: Git Reset** - Dangerous history rewriting - local cleanup only (NEVER on pushed commits!)
- **Module 03: Branching and Merging** - Create branches and merge them
- **Module 04: Merge Conflicts** - Resolve conflicts when branches have competing changes
- **Module 05: Cherry-Pick** - Apply specific commits from one branch to another
- **Module 06: Git Revert** - Safe undoing - preserve history while reversing changes
- **Module 07: Stash** - Temporarily save work without committing
- **Module 08: Multiplayer Git** - **The Great Print Project** - Real cloud-based collaboration with teammates
### 02 Advanced - Professional Techniques (6 modules)
Advanced Git workflows for power users:
- **Module 01: Rebasing** - Rebase branches to create linear history
- **Module 02: Interactive Rebase** - Clean up commit history before submitting pull requests
- **Module 03: Worktrees** - Work on multiple branches simultaneously
- **Module 04: Bisect** - Use binary search to find bug-introducing commits
- **Module 05: Blame** - Code archaeology - investigate who changed what and when
- **Module 06: Merge Strategies** - Master fast-forward vs three-way merges and when to use each
## How to Use This Workshop
### For Local Modules (01-08 in Essentials, all Advanced modules)
### For Local Modules (01-07)
1. Navigate to a module directory (e.g., `01-essentials/01-basics`)
2. Read the `README.md` to understand the challenge
@@ -65,12 +52,12 @@ Most modules include setup, verification, and reset scripts.
If you encounter an "execution policy" error when running scripts, open PowerShell as Administrator and run:
```powershell
```pwsh
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
Then run scripts using:
```powershell
```pwsh
.\setup.ps1
.\verify.ps1
.\reset.ps1
@@ -83,75 +70,98 @@ Then run scripts using:
Install these tools before starting:
**PowerShell 7+**
```powershell
```pwsh
winget install Microsoft.PowerShell
```
**Git 2.23+**
```powershell
```pwsh
winget install Git.Git
```
**Visual Studio Code**
```powershell
```pwsh
winget install Microsoft.VisualStudioCode
```
You can also run the one-shot install script if the project is cloned locally.
It will check if you have the prerequisites install and clone down the project
if not already cloned. Then it will configure git to have sane default.
```pwsh
./install.ps1
```
or if you don't have the project locally run.
REMEMBER read through the script before running it. As a general practice, you
shouldn't get comfortable doing this kind of execution, and so it's important
to review executing remote scripts.
```pwsh
Invoke-RestMethod -Uri https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | Invoke-Expression
```
### Quick Start
**Option 1: Oneshot Installation (Recommended)**
Install everything and clone the repository in one command:
1. **Install the prerequisites above**
2. **Clone this repository**
3. **Configure Git** (see below for recommended settings)
```powershell
irm https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | iex
```
## Git Configuration
**Option 2: Manual Setup**
1. Install the prerequisites above
2. Clone this repository:
```powershell
git clone https://git.frod.dk/floppydiscen/git-workshop.git
```
3. Configure Git:
```powershell
Before starting the workshop, configure Git with your identity and recommended settings:
### Required: Set Your Identity
```pwsh
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
```
**Quick Check:**
### Recommended: VS Code as Default Editor
You need the following software installed:
Set VS Code as your default editor for commit messages, diffs, and merges:
- **Git 2.23+** - Version control system
```powershell
```pwsh
# Set VS Code as the default editor
git config --global core.editor "code --wait"
# Set VS Code as the diff tool
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"
# Set VS Code as the merge tool
git config --global merge.tool vscode
git config --global mergetool.vscode.cmd "code --wait --merge $MERGED"
```
### Recommended: Set Default Branch Name
Set "main" as the default branch name for new repositories:
```pwsh
git config --global init.defaultBranch main
```
### Verify Your Configuration
Check that your settings are correct:
```pwsh
git config --global --list
```
**Verify Installation:**
Check that you have the required software installed:
```pwsh
# Git 2.23+
git --version
```
- **PowerShell 7+**
```powershell
# PowerShell 7+
pwsh --version
```
- **Python 3.6+** (for Module 08 only)
```powershell
python --version
```
**First-Time Git Configuration:**
Before making your first commit, configure Git with your identity:
```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
```
### Basic Command Line Knowledge
You should know how to:
@@ -161,31 +171,13 @@ You should know how to:
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
.\bin\glow.exe 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
- **Staging Area**: 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
@@ -199,11 +191,9 @@ Don't worry if these don't make sense yet - you'll learn them hands-on as you pr
## Getting Started
**First time?** Make sure you have Git and PowerShell installed - see [INSTALLATION.md](INSTALLATION.md) for Windows 11 setup instructions.
Once installed, start with Essentials Module 01:
```powershell
```pwsh
cd 01-essentials\01-basics
.\setup.ps1
```
@@ -213,7 +203,7 @@ 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 (modules 01-08)
- **Automated Verification**: Scripts check your solution instantly (modules 01-07)
- **Progressive Difficulty**: Builds from basics to advanced Git techniques
- **Reset Anytime**: Each local module includes a reset script for a fresh start
- **Self-Paced**: Learn at your own speed with detailed README guides
@@ -230,35 +220,26 @@ The modules are designed to build on each other:
- Git Basics, History
- **Goal**: Understand commits and history
**Phase 2: Collaboration Basics (Essentials 03)**
- Branching and Merging (checkpoint-based: branching, merging, conflicts)
**Phase 2: Collaboration Basics (Essentials 03-04)**
- Branching, Merging, and Conflict Resolution
- **Goal**: Work with multiple branches and resolve conflicts
**Phase 3: Workflow Tools (Essentials 04-06)**
- Cherry-Pick, Reset vs Revert, Stash
**Phase 3: Workflow Tools (Essentials 05-07)**
- Cherry-Pick, Revert, and Stash
- **Goal**: Manage your work effectively
**Phase 4: Real Collaboration (Essentials 07)**
- **Multiplayer Git - The Great Print Project**
**Phase 4: Real Collaboration (Essentials 08)**
- **Multiplayer Git - The Great Reordering of Numbers Project**
- **Goal**: Apply all skills with real teammates on a cloud server
- **Note**: This is a capstone module - bring everything together!
**Phase 5: Advanced Techniques (Advanced 01-06)**
- Rebasing, Interactive Rebase, Worktrees, Bisect, Blame, Merge Strategies
- **Goal**: Master professional Git workflows
- **When**: After completing Essentials and feeling confident
### Alternative Paths
**Fast Track (1 day workshop):**
- Essentials 01-03 + Essentials 07 (Multiplayer)
**Solo Learner:**
- Complete Essentials 01-06, skip 07 (requires partners and server)
- Or complete all Advanced modules for deep mastery
**Fast Track (half-day workshop):**
- Essentials 01-04 + Essentials 08 (Multiplayer)
**Team Workshop:**
- Essentials 01-03 then jump to 07 (Multiplayer) for collaborative practice
- Essentials 01-04 then jump to 08 (Multiplayer) for collaborative practice
## Tips for Success
@@ -266,118 +247,28 @@ The modules are designed to build on each other:
- **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
- **Use `git status` and `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
- **For Module 07**, work with a partner - collaboration is the point!
- **For Module 08**, work with a partner - collaboration is the point!
## Skills You'll Master
By completing this workshop, you'll be able to:
### From Essentials Track:
- ✅ 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
- ✅ Apply specific commits with cherry-pick
- ✅ Choose correctly between reset and revert
- ✅ Use stash to manage work-in-progress without commits
- ✅ **Collaborate with teammates on shared repositories**
- ✅ **Resolve real merge conflicts in a team environment**
- ✅ **Create and review pull requests**
- ✅ **Use Git on a real cloud server (Azure DevOps)**
- ✅ **Use SSH keys for secure Git authentication**
- 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
- Apply specific commits with cherry-pick
- Safely undo changes with revert
- Use stash to manage work-in-progress without commits
- **Collaborate with teammates on shared repositories**
- **Resolve real merge conflicts in a team environment**
- **Create and review pull requests**
- **Use Git on a real cloud server (Azure DevOps)**
- **Use SSH keys for secure Git authentication**
### From Advanced Track:
- ✅ Rebase to maintain clean, linear history
- ✅ Clean up messy commits before submitting pull requests
- ✅ Work on multiple branches simultaneously with worktrees
- ✅ Debug efficiently by finding bug-introducing commits with bisect
- ✅ Investigate code history with git blame
- ✅ Master different merge strategies and when to use each
These are professional-level Git skills used daily by developers at top tech companies.
## For Workshop Facilitators
This repository can be used for **self-paced learning** or as a **facilitated workshop**.
### Self-Paced Distribution
Before distributing this workshop to attendees for self-study:
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
**Note**: Module 08 (Multiplayer) requires you to set up a Git server - see facilitator guide below.
### Facilitated Workshop
For running this as a full-day instructor-led workshop:
1. **See [WORKSHOP-AGENDA.md](WORKSHOP-AGENDA.md)** - Complete agenda with timing, activities, and facilitation tips
2. **See [PRESENTATION-OUTLINE.md](PRESENTATION-OUTLINE.md)** - Slide deck outline for presentations
3. **Workshop covers:** Essentials 01-05 + Module 08 (Multiplayer collaboration exercise)
4. **Duration:** 6-7 hours including breaks
5. **Format:** Mix of presentation, live demos, and hands-on challenges
**Facilitator preparation:**
- Review the workshop agenda thoroughly
- Set up Git server for Module 08 (see below)
- Ensure all participants have prerequisites installed (Git, PowerShell, Python)
- Prepare slides using the presentation outline
- Test all modules on a clean machine
- Create student accounts on your Git server
The workshop format combines instructor-led sessions with self-paced hands-on modules for an engaging learning experience.
### Setting Up Module 08: Multiplayer Git
Module 08 requires a Git server for authentic collaboration using **Azure DevOps**.
**Azure DevOps Setup**
Use Azure DevOps as the cloud-based Git platform for this module:
**Benefits:**
- 💰 Free tier supports up to 5 users with full access
- 🌐 Cloud-hosted - no server maintenance required
- 🔒 Enterprise-grade security and reliability
- 🔑 Built-in SSH key support (industry best practice)
- 👥 Perfect for workshops with any number of students (use Stakeholder licenses for >5 users)
- 📊 Built-in pull request workflows and code review tools
**Setup Steps:**
1. **Create Azure DevOps Organization** (if you don't have one):
- Sign up at [dev.azure.com](https://dev.azure.com) with a Microsoft account
- Create a new organization for your workshop
2. **Set up SSH authentication** (recommended for all users):
- See [AZURE-DEVOPS-SSH-SETUP.md](AZURE-DEVOPS-SSH-SETUP.md) for complete SSH key setup instructions
- SSH provides secure, passwordless authentication (industry standard)
3. **Configure workshop repository and users**:
- See `01-essentials/08-multiplayer/FACILITATOR-SETUP.md` for detailed workshop preparation:
- Adding student accounts to Azure DevOps
- Creating The Great Print Project repository
- Configuring branch policies
- Pairing students
- Monitoring progress
- Troubleshooting SSH and authentication issues
**Alternative: GitHub / GitLab / Bitbucket**
While this workshop uses Azure DevOps, the skills learned apply to any Git platform:
- The workflow is identical across all platforms
- SSH authentication works the same way everywhere
- Pull request concepts transfer directly
- Students can apply these skills to any Git hosting service
These are professional-level Git skills used daily by developers at tech companies.
---
@@ -386,117 +277,23 @@ While this workshop uses Azure DevOps, the skills learned apply to any Git platf
```
git-workshop/
├── README.md # This file
├── INSTALLATION.md # Windows 11 installation guide (PowerShell 7, Git, VS Code)
├── install-prerequisites.ps1 # Automated installation script (one-shot setup)
├── INSTALLATION.md # Installation guide
├── install.ps1 # Automated installation script
├── GIT-CHEATSHEET.md # Quick reference for all Git commands
├── WORKSHOP-AGENDA.md # Facilitator guide for running workshops
├── PRESENTATION-OUTLINE.md # Slide deck outline
├── AZURE-DEVOPS-SSH-SETUP.md # SSH authentication best practices for Azure DevOps
├── install-glow.ps1 # Install glow markdown renderer
├── BEST-PRACTICES.md # Git best practices
├── COMMIT-MESSAGES.md # Guide to writing good commit messages
├── WHAT-IS-GIT.md # Introduction to Git concepts
── 01-essentials/ # Core Git skills (8 modules)
├── 01-basics/ # Initialize, commit, status
├── 02-history/ # Log, diff, show
├── 03-branching-and-merging/ # Branches, merging, conflicts (checkpoint-based)
├── 04-cherry-pick/ # Apply specific commits
├── 05-revert/ # Safe undoing (includes merge commits)
├── 06-reset/ # Dangerous local cleanup
├── 07-stash/ # Save work-in-progress
└── 08-multiplayer/ # Real collaboration (cloud-based)
├── README.md # Student guide
── FACILITATOR-SETUP.md # Server setup guide
└── 02-advanced/ # Professional techniques (6 modules)
├── 01-rebasing/ # Linear history with rebase
├── 02-interactive-rebase/ # Clean up commits
├── 03-worktrees/ # Multiple branches simultaneously
├── 04-bisect/ # Find bugs with binary search
├── 05-blame/ # Code archaeology
└── 06-merge-strategies/ # Master merge techniques
── 01-essentials/ # Core Git skills (8 modules)
├── 01-basics/ # Initialize, commit, status
├── 02-history/ # Log, diff, show
├── 03-branching-and-merging/ # Branches and merging
├── 04-merge-conflict/ # Resolve merge conflicts
├── 05-cherry-pick/ # Apply specific commits
├── 06-revert/ # Safe undoing
├── 07-stash/ # Save work-in-progress
└── 08-multiplayer/ # Real collaboration (cloud-based)
├── README.md # Student guide
── 01_FACILITATOR.md # Facilitator setup guide
└── 02_AZURE-DEVOPS-SSH-SETUP.md # SSH authentication guide
```
## What's Unique About This Workshop
### The Great Print Project (Module 08)
Unlike any other Git tutorial, Module 08 provides **real collaborative experience**:
- **Real Git server**: Not simulated - actual Azure DevOps cloud repository
- **Real teammates**: Work in pairs on shared branches
- **Real conflicts**: Both partners edit the same code and must resolve conflicts together
- **Real pull requests**: Create PRs, review code, merge to main
- **Real success**: When all pairs merge, run `python main.py` and see everyone's contributions!
- **Real security**: Use SSH keys for authentication (industry best practice)
**The challenge**: Each pair implements 3 Python functions (e.g., `print_b()`, `print_c()`, `print_d()`) in a shared repository. When complete, the program prints the alphabet A-Z and numbers 0-9.
**What students learn**:
- Push/pull workflow with real teammates
- Handling rejected pushes (partner pushed first!)
- Resolving actual merge conflicts (not simulated)
- Creating meaningful pull requests
- Reviewing others' code
- Staying synchronized with a team
This is how professional developers actually work - no simulation, no shortcuts.
---
## Frequently Asked Questions
**Q: Do I need to complete all modules?**
A: No! Essentials 01-05 covers what most developers use daily. Complete 06-09 and Advanced modules to deepen your skills.
**Q: Can I do Module 08 (Multiplayer) without a partner?**
A: Not recommended - collaboration is the point. If solo, skip to Advanced modules or wait until you can pair with someone.
**Q: How long does the workshop take?**
A:
- Essentials 01-05: 3-4 hours
- Full Essentials (01-09): 6-7 hours
- All modules: 12-15 hours
- Self-paced over several days works great!
**Q: I'm stuck on a module. What should I do?**
A:
1. Re-read the module README.md
2. Check [GIT-CHEATSHEET.md](GIT-CHEATSHEET.md)
3. Run `./reset.ps1` to start fresh
4. Use `git status` and `git log --graph` to understand current state
5. For Module 08, ask your partner or facilitator
**Q: Can I use this for a team workshop at my company?**
A: Absolutely! See the "For Workshop Facilitators" section above. The materials are designed for both self-study and instructor-led workshops.
**Q: Do I need internet access?**
A: Modules 01-07 work completely offline. Module 08 requires internet to access the Git server.
**Q: What if I prefer GitHub/GitLab instead of Azure DevOps?**
A: The skills are identical across all Git platforms. Module 08 uses Azure DevOps but everything you learn applies directly to GitHub, GitLab, Bitbucket, and any other Git hosting service. The SSH authentication, pull request workflow, and collaboration patterns are the same everywhere.
---
## Contributing
Found a bug or have a suggestion? Please open an issue or submit a pull request!
---
## License
This workshop is provided as-is for educational purposes.
---
**Ready to master Git?**
First-time setup (Windows 11): See [INSTALLATION.md](INSTALLATION.md)
Then start with Essentials Module 01 and begin your journey!
```powershell
cd 01-essentials\01-basics
.\setup.ps1
```
Happy Learning! 🚀

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Installs all prerequisites for Git Workshop using winget and clones the repository.
Installs all prerequisites for Git Workshop using winget (which is a CLI
tool to the Windows Package Manager Server) and clones the workshop
repository.
.DESCRIPTION
This script automates the installation of required tools for the Git Workshop:
@@ -17,9 +19,11 @@ each installation succeeded. At the end, it clones the repository and can
open it in VSCode for immediate workshop access.
One-shot installation:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | Invoke-Expression
.EXAMPLE
PS> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
PS> Invoke-RestMethod -Uri https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | Invoke-Expression
Runs the complete installation and setup in one command.
@@ -638,17 +642,21 @@ if ($userChoice -ne "CloneOnly") {
Write-Host " Setting the init.defaultBranch to be 'main'"
git config --global init.defaultBranch main
Write-Success " Set 'main' as default branch"
Write-Host " Setting the default editor to code, to handle merge messages"
git config --global core.editor "code --wait"
Write-Success " Visual Studio Code set as core.editor"
Write-Host " Setting vscode at the default code editor for merge conflicts"
git config --global merge.tool vscode
git config --global mergetool.vscode.cmd 'code --wait --merge $REMOTE $LOCAL $BASE $MERGED'
git config --global mergetool.vscode.cmd 'code --wait --merge $MERGED'
Write-Success " Visual Studio Code set as mergetool"
Write-Host " Setting vscode as the default code editor for diffs"
git config --global diff.tool vscode
git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'
Write-Success " Visual Studio Code set as difftool"
# Verify Git version specifically
if ($results.Git) {