Add lesson 7: Undoing things

Mira Kovac 1 year ago
parent 9cf7c6d087 commit ba2a3cc3b2b8880f83fb8b364daa1eb1e5be1502
3 changed files with 29 additions and 0 deletions
+19-0lessons/07-undoing-things/README.md ADDED
@@ -0,0 +1,19 @@
1+# Lesson 7: Undoing things
2+
3+This lesson covers undoing things. You'll read a short explanation, try three small exercises and finish with a quiz.
4+
5+Full lesson: [https://glibcode.net/courses/git-github/lessons/7](https://glibcode.net/courses/git-github/lessons/7)
6+
7+## Files
8+
9+- `commands.sh`: restore, reset and revert
10+
11+## Run it
12+
13+```sh
14+# type the commands from commands.sh one by one; don't run it as a script
15+```
16+
17+## Exercises
18+
19+See [exercises.md](exercises.md). Ask in the forum once you've tried.
+5-0lessons/07-undoing-things/commands.sh ADDED
@@ -0,0 +1,5 @@
1+git restore notes.txt # throw away unstaged changes
2+git restore --staged notes.txt # unstage, keep the changes
3+git revert HEAD # undo the last commit with a new one
4+git reset --soft HEAD~1 # un-commit, keep the work staged (local commits only!)
5+git reflog # your safety net
+5-0lessons/07-undoing-things/exercises.md ADDED
@@ -0,0 +1,5 @@
1+# Exercises: lesson 7
2+
3+1. Add a check that prints a warning when a result looks wrong (negative, empty, too big).
4+2. Run `commands.sh` and change one value. Write down what you expect, then run it again and compare.
5+3. Time yourself: rewrite the example from memory in 10 minutes, then diff it against the original.