From cdd695b2505479cd9a15da2c7337a2e7003bfeac Mon Sep 17 00:00:00 2001 From: Bjarke Sporring Date: Thu, 15 Jan 2026 16:29:06 +0100 Subject: [PATCH] fix: cleanup revert module --- 01-essentials/06-revert/README.md | 104 ++---------------------------- 1 file changed, 4 insertions(+), 100 deletions(-) diff --git a/01-essentials/06-revert/README.md b/01-essentials/06-revert/README.md index 57bd780..38a12d0 100644 --- a/01-essentials/06-revert/README.md +++ b/01-essentials/06-revert/README.md @@ -293,10 +293,10 @@ Use `git revert` when: Consider alternatives when: -- ❌ **Commits are still local** - Use `git reset` instead (Module 06) +- ❌ **Commits are still local** - Use `git reset` instead (advanced module) - ❌ **Just want to edit a commit** - Use `git commit --amend` -- ❌ **Haven't pushed yet** - Reset is cleaner for local cleanup -- ❌ **Need to combine commits** - Use interactive rebase +- ❌ **Haven't pushed yet** - Reset is cleaner for local cleanup, but more dangerous, stick to revert if in doubt +- ❌ **Need to combine commits** - Use interactive rebase IF nothing has been pushed to cloud - ❌ **Reverting creates complex conflicts** - Might need manual fix forward ## Revert vs. Reset vs. Rebase @@ -344,7 +344,7 @@ git revert --abort ### 1. Using Reset on Pushed Commits ```pwsh -# ❌ NEVER do this with pushed commits +# ❌ NEVER do this with pushed commits. Or at least try your best to avoid it. git reset --hard HEAD~3 # ✅ Do this instead @@ -398,99 +398,3 @@ git revert C - Revert the minimum necessary - Don't bundle multiple unrelated reverts - One problem = one revert commit - -## Troubleshooting - -### "Empty Revert / No Changes" - -**Problem:** Revert doesn't seem to do anything. - -**Possible causes:** -- Commit was already reverted -- Subsequent commits already undid the changes -- Wrong commit hash - -**Solution:** -```pwsh -# Check what the commit actually changed -git show - -# Check if already reverted -git log --grep="Revert" -``` - -### "Conflicts During Revert" - -**Problem:** Revert causes merge conflicts. - -**Why:** Subsequent commits modified the same code. - -**Solution:** -1. Manually resolve conflicts in affected files -2. `git add ` -3. `git revert --continue` - -Or consider fixing forward with a new commit instead of reverting. - -### "Reverting Old Commit Breaks Something" - -**Problem:** After reverting an old commit, something else stops working. - -**Why:** The old commit might have been a dependency for later commits. - -**Solution:** -1. Check what changed: `git diff HEAD~1 HEAD` -2. Either fix the issue with a new commit, or -3. Revert the revert if needed: `git revert ` - -## Advanced: Revert Internals - -Understanding what revert does under the hood: - -```pwsh -# Revert creates a new commit with inverse changes -git revert - -# This is equivalent to: -git diff ^.. > changes.patch -patch -R < changes.patch # Apply in reverse -git add . -git commit -m "Revert ''" -``` - -**Key insight:** Revert computes the diff of the target commit, inverts it, and applies it as a new commit. - -## Going Further - -Now that you understand revert, you're ready for: - -- **Module 06: Git Reset** - Learn the dangerous but powerful local history rewriting -- **Module 07: Git Stash** - Temporarily set aside uncommitted changes -- **Module 08: Multiplayer Git** - Collaborate with advanced workflows - -## Summary - -You've learned: - -- ✅ `git revert` creates new commits that undo previous changes -- ✅ Revert is safe for shared/pushed commits -- ✅ Commits before and after the reverted commit are preserved -- ✅ Multiple commits can be reverted in one command -- ✅ Revert preserves complete history for audit trails - -**The Golden Rule of Revert:** Use revert for any commit that might be shared with others. - -## Next Steps - -1. Complete both challenge scenarios -2. Run `.\verify.ps1` to check your solutions -3. Experiment with reverting different commits -4. Move on to Module 07: Git Reset (dangerous but powerful!) - ---- - -**Need Help?** -- Review the command reference above -- Check the troubleshooting section -- Re-run `./setup.ps1` to start fresh -- Practice reverting in different orders to understand the behavior