mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2025-05-29 20:29:00 +02:00
Reorder levels and chapters into a better sequence
This commit is contained in:
parent
5c1f1ce722
commit
c99a35d54f
40 changed files with 128 additions and 288 deletions
94
levels/changing-the-past/rebase
Normal file
94
levels/changing-the-past/rebase
Normal file
|
@ -0,0 +1,94 @@
|
|||
title = Rebasing
|
||||
cards = checkout commit-auto reset-hard rebase
|
||||
|
||||
[description]
|
||||
|
||||
Okay - turns out that saving time in the morning by utilizing parallel universes is against the regulations of the International Time Travel Association. You'll have to do your tasks in sequence after all.
|
||||
|
||||
See the "rebase" card? When you drag it to a commit, it will copy the events in your current timeline after the specified one! This way, make a clean, linear timeline where you visit all three shops.
|
||||
|
||||
Again, we want to make that our base reality - the "main" branch should point to that timeline!
|
||||
|
||||
[setup]
|
||||
|
||||
echo "A friendly old lady.
|
||||
Sells delicious baguettes." > mary
|
||||
|
||||
echo "A rebellious teenager.
|
||||
Sells good coffee." > larry
|
||||
|
||||
echo "A snail. Literally a snail.
|
||||
Sells donuts with an unspecified, slimy filling." > gary
|
||||
|
||||
echo "You do not have a baguette.
|
||||
|
||||
You do not have coffee.
|
||||
|
||||
You do not have a donut." > you
|
||||
|
||||
git add .
|
||||
git commit -m "The Beginning"
|
||||
|
||||
git checkout -b coffee
|
||||
echo "You have a baguette.
|
||||
|
||||
You do not have coffee.
|
||||
|
||||
You do not have a donut." > you
|
||||
git add .
|
||||
git commit -m "You buy a baguette"
|
||||
|
||||
echo "You ate a baguette.
|
||||
|
||||
You do not have coffee.
|
||||
|
||||
You do not have a donut." > you
|
||||
git add .
|
||||
git commit -m "You eat the baguette"
|
||||
|
||||
git checkout -b baguette main
|
||||
echo "You do not have a baguette.
|
||||
|
||||
You have coffee.
|
||||
|
||||
You do not have a donut." > you
|
||||
git add .
|
||||
git commit -m "You buy some coffee"
|
||||
|
||||
echo "You do not have a baguette.
|
||||
|
||||
You drank coffee.
|
||||
|
||||
You do not have a donut." > you
|
||||
git add .
|
||||
git commit -m "You drink the coffee"
|
||||
|
||||
git checkout -b donut main
|
||||
echo "You do not have a baguette.
|
||||
|
||||
You do not have coffee.
|
||||
|
||||
You have a donut." > you
|
||||
git add .
|
||||
git commit -m "You buy a donut"
|
||||
|
||||
echo "You do not have a baguette.
|
||||
|
||||
You do not have coffee.
|
||||
|
||||
You ate a donut." > you
|
||||
git add .
|
||||
git commit -m "You eat the donut"
|
||||
|
||||
git checkout --detach main
|
||||
|
||||
|
||||
[win]
|
||||
|
||||
{ git show main:you | grep "You ate.*baguette"; } && { git show main:you | grep "You drank.*coffee"; } && { git show main:you | grep "You ate.*donut"; } && { test "$(git log main --oneline | wc -l)" -eq 7; }
|
||||
|
||||
[congrats]
|
||||
|
||||
Notice how the other timelines and commits are still there - if anything goes wrong, you can also travel back to them.
|
||||
|
||||
It's really hard to actually *destroy* stuff with your time machine.
|
77
levels/changing-the-past/reorder
Normal file
77
levels/changing-the-past/reorder
Normal file
|
@ -0,0 +1,77 @@
|
|||
title = Reordering events
|
||||
cards = checkout commit-auto reset-hard rebase-interactive cherry-pick
|
||||
|
||||
[description]
|
||||
|
||||
Oops, looks like there's something messed up here. Can you put the events back into their correct order?
|
||||
|
||||
There are two ways to do this: You can drag the "interactive rebase" card to the commit before the one you want to change, then reorder the lines in the file that opens, and save it.
|
||||
|
||||
Or you can reset the main tag to the very first commit, and then cherry-pick single commits in the order you want. You have cards for both approaches!
|
||||
|
||||
[setup]
|
||||
|
||||
echo "You just woke up.
|
||||
|
||||
You are NOT wearing underwear.
|
||||
|
||||
You are NOT wearing pants.
|
||||
|
||||
You are NOT wearing a shirt.
|
||||
|
||||
You are NOT wearing shoes." > you
|
||||
git add .
|
||||
|
||||
git commit -m "The Beginning"
|
||||
|
||||
echo "You just woke up.
|
||||
|
||||
You are NOT wearing underwear.
|
||||
|
||||
You are NOT wearing pants.
|
||||
|
||||
You are NOT wearing a shirt.
|
||||
|
||||
You are wearing shoes." > you
|
||||
git commit -am "Put on shoes"
|
||||
|
||||
echo "You just woke up.
|
||||
|
||||
You are NOT wearing underwear.
|
||||
|
||||
You are wearing pants.
|
||||
|
||||
You are NOT wearing a shirt.
|
||||
|
||||
You are wearing shoes." > you
|
||||
git commit -am "Put on pants"
|
||||
|
||||
echo "You just woke up.
|
||||
|
||||
You are wearing underwear.
|
||||
|
||||
You are wearing pants.
|
||||
|
||||
You are NOT wearing a shirt.
|
||||
|
||||
You are wearing shoes." > you
|
||||
git commit -am "Put on underwear"
|
||||
|
||||
echo "You just woke up.
|
||||
|
||||
You are wearing underwear.
|
||||
|
||||
You are wearing pants.
|
||||
|
||||
You are wearing a shirt.
|
||||
|
||||
You are wearing shoes." > you
|
||||
git commit -am "Put on shirt"
|
||||
|
||||
[win]
|
||||
|
||||
{ git log main --oneline | grep -Pz "shoes[\s\S]*pants[\s\S]*underwear"; } && { test "$(git log main --oneline | wc -l)" -eq 5; }
|
||||
|
||||
[congrats]
|
||||
|
||||
Feel free to reset the level and try the other strategy! Which one do you like better?
|
26
levels/changing-the-past/split
Normal file
26
levels/changing-the-past/split
Normal file
|
@ -0,0 +1,26 @@
|
|||
title = Split a commit!
|
||||
cards = checkout commit reset-hard reset add rebase-interactive rebase-continue show
|
||||
|
||||
[description]
|
||||
|
||||
Here, both changes happened in one commit! Split them to be in two commits instead.
|
||||
|
||||
[setup]
|
||||
|
||||
echo something > file1
|
||||
echo something else > file2
|
||||
git add .
|
||||
git commit -m "Initial commit"
|
||||
|
||||
echo this should happen first >> file1
|
||||
echo and this should happen after that >> file2
|
||||
git commit -am "Both together"
|
||||
|
||||
echo this is some other change >> file1
|
||||
echo this is some other change >> file2
|
||||
git commit -am "Something else"
|
||||
|
||||
[win]
|
||||
|
||||
test "$(git diff-tree --no-commit-id --name-status -r main^)" = "M file2" &&
|
||||
test "$(git diff-tree --no-commit-id --name-status -r main~2)" = "M file1"
|
23
levels/changing-the-past/steps
Normal file
23
levels/changing-the-past/steps
Normal file
|
@ -0,0 +1,23 @@
|
|||
title = One step after another
|
||||
cards = checkout commit reset-hard add
|
||||
|
||||
[description]
|
||||
|
||||
Sometimes, you might want to record the order in which things changed, instead of making a single commit.
|
||||
|
||||
What happened here? Make two commits from the changes (using the "add" card), in an order that makes sense!
|
||||
|
||||
[setup]
|
||||
|
||||
echo something > file1
|
||||
echo something else > file2
|
||||
git add .
|
||||
git commit -m "Initial commit"
|
||||
|
||||
echo this should happen first >> file1
|
||||
echo and this should happen after that >> file2
|
||||
|
||||
[win]
|
||||
|
||||
test "$(git diff-tree --no-commit-id --name-status -r main)" = "M file2" &&
|
||||
test "$(git diff-tree --no-commit-id --name-status -r main^)" = "M file1"
|
Loading…
Add table
Add a link
Reference in a new issue