fix: remove revert-middle challenge

This commit is contained in:
Bjarke Sporring
2026-01-15 16:23:32 +01:00
parent 575e083f33
commit 0474a6de0e
3 changed files with 20 additions and 238 deletions

View File

@@ -18,10 +18,9 @@ Welcome to Module 06, where you'll learn the **safe, team-friendly way to undo c
By completing this module, you will:
1. Revert commits safely while preserving surrounding changes
2. Revert old commits in the middle of history
3. Understand how revert preserves commits before and after the target
4. Revert multiple commits at once
5. Know when to use revert vs. other undo strategies
2. Understand how revert creates new commits instead of erasing history
3. Revert multiple commits at once
4. Know when to use revert vs. other undo strategies
## Prerequisites
@@ -38,9 +37,8 @@ Run the setup script to create the challenge environment:
.\setup.ps1
```
This creates a `challenge/` directory with three branches demonstrating different revert scenarios:
This creates a `challenge/` directory with two branches demonstrating different revert scenarios:
- `regular-revert` - Basic commit reversion
- `middle-revert` - Reverting a commit in the middle of history
- `multi-revert` - Multiple commit reversion
## Challenge 1: Reverting a Regular Commit
@@ -119,110 +117,7 @@ main.py (initial) → multiply (good) → divide (BAD) → modulo (good) → rev
The revert commit adds a new point in history that undoes the divide changes.
## Challenge 2: Reverting a Commit in the Middle
### Scenario
You're working on improving your calculator application. Several commits were made in sequence:
1. Added input validation (good)
2. Added output formatter (BAD - has bugs!)
3. Added configuration module (good - but came after the bad commit)
The formatter has critical bugs and needs to be removed, but you want to keep both the validation module (added before) and the configuration module (added after).
**This demonstrates an important Git principle:** Revert works on ANY commit in history, not just recent ones!
### Understanding History Preservation
Here's what the commit history looks like:
```
A (initial) → B (validation) → C (formatter BAD) → D (config)
We want to remove THIS
```
When you revert commit C:
```
A (initial) → B (validation) → C (formatter BAD) → D (config) → E (revert C)
Removes formatter, keeps validation & config
```
**Key insight:** The revert creates a NEW commit (E) that undoes commit C, but leaves B and D completely intact!
### Your Task
1. **Switch to the middle-revert branch:**
```pwsh
git switch middle-revert
```
2. **View the commit history:**
```pwsh
git log --oneline
```
You should see three commits after the initial:
- "Add input validation module"
- "Add broken formatter - needs to be reverted!"
- "Add configuration module"
3. **Find the broken formatter commit:**
- Look for the message: "Add broken formatter - needs to be reverted!"
- Note the commit hash (the 7-character code)
- Write it down
4. **Revert that middle commit** (replace `<commit-hash>` with actual hash):
```pwsh
git revert <commit-hash>
```
5. **Visual Studio Code will open** with the revert commit message:
- The default message is fine
- Close the editor window to accept it
- Git will create the revert commit
6. **Check the result:**
```pwsh
# View files - formatter.py should be gone
ls
# You should see validation.py and config.py but NOT formatter.py
# View the history
git log --oneline
# You should see the new revert commit at the top
```
### What to Observe
After reverting, notice:
```pwsh
# Check which files exist
ls
# You should see:
# - calculator.py (from initial commit)
# - validation.py (from commit BEFORE bad one) ✅
# - config.py (from commit AFTER bad one) ✅
# - formatter.py is GONE (reverted) ❌
```
**Important:** Git successfully removed the bad formatter while keeping everything else!
### Why This Matters
This scenario demonstrates revert's power in real-world situations:
- You discover a bug in code committed days or weeks ago
- Many commits have been made since then
- You can't just delete the old commit (that would break history)
- Revert lets you surgically remove just the bad commit
**Revert is your "undo button" for shared history!**
## Challenge 3: Reverting Multiple Commits
## Challenge 2: Reverting Multiple Commits
### Scenario
@@ -303,7 +198,7 @@ This is useful when reverting multiple commits and you want one combined revert
## Verification
After completing all three challenges, verify your solutions:
After completing both challenges, verify your solutions:
```pwsh
cd .. # Return to module directory (if you're in challenge/)
@@ -320,7 +215,6 @@ The script checks that:
- ✅ Revert commits were created (not destructive deletion)
- ✅ Bad code is removed
- ✅ Good code before and after is preserved
- ✅ Revert works on commits in the middle of history
## Command Reference
@@ -580,7 +474,6 @@ You've learned:
- ✅ `git revert` creates new commits that undo previous changes
- ✅ Revert is safe for shared/pushed commits
- ✅ Revert works on any commit in history, even old ones
- ✅ Commits before and after the reverted commit are preserved
- ✅ Multiple commits can be reverted in one command
- ✅ Revert preserves complete history for audit trails
@@ -589,10 +482,10 @@ You've learned:
## Next Steps
1. Complete all three challenge scenarios
2. Run `./verify.ps1` to check your solutions
1. Complete both challenge scenarios
2. Run `.\verify.ps1` to check your solutions
3. Experiment with reverting different commits
4. Move on to Module 06: Git Reset (dangerous but powerful!)
4. Move on to Module 07: Git Reset (dangerous but powerful!)
---