Add lesson 4: Merging and conflicts

Mira Kovac 1 year ago
parent 8bea72d8a8 commit 8067154f4ba13dc239d17e236e2b9b8770ad7548
3 changed files with 32 additions and 0 deletions
+19-0lessons/04-merging-and-conflicts/README.md ADDED
@@ -0,0 +1,19 @@
1+# Lesson 4: Merging and conflicts
2+
3+In this lesson you'll work through merging and conflicts step by step, with short exercises after each idea.
4+
5+Full lesson: [https://glibcode.net/courses/git-github/lessons/4](https://glibcode.net/courses/git-github/lessons/4)
6+
7+## Files
8+
9+- `commands.sh`: a merge with a conflict and how to finish it
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.
+8-0lessons/04-merging-and-conflicts/commands.sh ADDED
@@ -0,0 +1,8 @@
1+git switch -c colors
2+sed -i 's/blue/green/' style.css && git commit -am "Green buttons"
3+git switch main
4+sed -i 's/blue/red/' style.css && git commit -am "Red buttons"
5+git merge colors # CONFLICT (content): Merge conflict in style.css
6+# edit style.css, keep the colour you want, remove the <<<<<<< ======= >>>>>>> lines
7+git add style.css
8+git commit # finishes the merge
+5-0lessons/04-merging-and-conflicts/exercises.md ADDED
@@ -0,0 +1,5 @@
1+# Exercises: lesson 4
2+
3+1. Add a comment above each block explaining what it does, in your own words.
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.