mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2025-05-01 20:42:01 +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
levels/branches
35
levels/branches/branch-create
Normal file
35
levels/branches/branch-create
Normal file
|
@ -0,0 +1,35 @@
|
|||
title = Party Time
|
||||
cards = checkout commit-auto reset-hard branch
|
||||
|
||||
[description]
|
||||
|
||||
You were invited to two parties but they will happen at the same time! At party 1 your favorite band is playing and the other one is your best friend's birthday party.
|
||||
|
||||
Where should you go? No worries - you are a time travel agent in training. You can go to both parties! To quickly switch between both events, check out the last commits and
|
||||
create branches with the `git branch [string]` command. Now you can easily switch between both branches by calling `git checkout [branch]`.
|
||||
|
||||
[setup]
|
||||
|
||||
echo "-Birthday present.
|
||||
-Concert ticket." > backpack
|
||||
git add .
|
||||
git commit -m "evening preparations"
|
||||
echo "-Birthday present." > backpack
|
||||
git add .
|
||||
git commit -m "go to the birthday"
|
||||
|
||||
git checkout HEAD~1
|
||||
echo "-Concert ticket." > backpack
|
||||
git add .
|
||||
git commit -m "go to the concert"
|
||||
|
||||
git checkout HEAD~1
|
||||
|
||||
[win]
|
||||
|
||||
NUM_BRANCHES="$(git show-ref --heads | wc -l)"
|
||||
test "$NUM_BRANCHES" -ge 3
|
||||
|
||||
[congrats]
|
||||
|
||||
Your friend is happy that you made it to the birthday party and you also got your concert ticket signed. Yay!
|
47
levels/branches/branch-remove
Normal file
47
levels/branches/branch-remove
Normal file
|
@ -0,0 +1,47 @@
|
|||
title = Choose your own adventure
|
||||
cards = checkout commit-auto reset-hard branch-delete
|
||||
|
||||
[description]
|
||||
|
||||
Life is full of dangers, right? Even when walking to school, it seems like there's a lot of risks!
|
||||
|
||||
This Monday is especially bad. You made it to school, but there's some timelines you definitely don't want to keep around.
|
||||
|
||||
Find the bad branches and delete them. Keep the one that seems okay.
|
||||
|
||||
[setup]
|
||||
|
||||
echo You leave your house and start walking to school. > you
|
||||
git add .
|
||||
git commit -m "Good morning!"
|
||||
|
||||
echo You walk on the right side of the street. >> you
|
||||
git commit -am "Right side"
|
||||
|
||||
echo You jump over an manhole in the walkway, and arrive at school on time. >> you
|
||||
git commit -am "Jump"
|
||||
|
||||
git checkout HEAD^ -b friend
|
||||
echo Suddenly, you fall down, splash into stinking water, and are eaten by an alligator. >> you
|
||||
git commit -am "A new friend"
|
||||
|
||||
git checkout HEAD~2 -b music
|
||||
echo You walk on the left side of the street. >> you
|
||||
git commit -am "Left side"
|
||||
|
||||
echo Because you\'re kind of late, you start running. Someone throws a piano out of their windows, and it smashes you. >> you
|
||||
git commit -am "Sounds nice"
|
||||
|
||||
git checkout HEAD^ -b ice-cream
|
||||
echo You\'re not in a hurry, and walk slowly. You even get some ice cream on your way. You arrive at school too late, and your teacher is angry. >> you
|
||||
git commit -am "Yum"
|
||||
|
||||
git checkout main
|
||||
|
||||
[win]
|
||||
|
||||
test "$(git branch | cut -c 3-)" = "$(echo -e ice-cream\\nmain)"
|
||||
|
||||
[congrats]
|
||||
|
||||
On second thought, maybe you even prefer the ice cream timeline to the main one? :)
|
103
levels/branches/branches
Normal file
103
levels/branches/branches
Normal file
|
@ -0,0 +1,103 @@
|
|||
title = Branching out
|
||||
cards = checkout commit-auto merge reset-hard
|
||||
|
||||
[description]
|
||||
|
||||
You can use these little blue labels to give names to different timelines! This makes it easier to remember what happened where.
|
||||
|
||||
One of your colleagues messed up here - can you help reordering the branches correctly using the "reset" card?
|
||||
|
||||
When you do commits or merges while you're on a branch, the branch will grow with you. Try that while you eat that donut.
|
||||
|
||||
Finally, merge all timelines together, in a way so that the "main" branch points to the result. That's base reality!
|
||||
|
||||
---
|
||||
tipp1
|
||||
---
|
||||
tipp2
|
||||
---
|
||||
tipp3
|
||||
|
||||
[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"
|
||||
|
||||
git checkout --detach main
|
||||
|
||||
[win]
|
||||
|
||||
# Did you eat a baguette on the main branch?
|
||||
git show main:you | grep "You ate.*baguette"
|
||||
|
||||
# Did you drink a coffee on the main branch?
|
||||
git show main:you | grep "You drank.*coffee"
|
||||
|
||||
# Did you eat a donut on the main branch?
|
||||
git show main:you | grep "You ate.*donut"
|
||||
|
||||
[actions]
|
||||
|
||||
test "$(git rev-parse HEAD^)" = "$(git rev-parse donut)" && hint "Ooops, your branch ref is still on the old commit."
|
||||
|
||||
[congrats]
|
||||
|
||||
Nice! It's often convenient to stay on branches most of the time!
|
53
levels/branches/branching
Normal file
53
levels/branches/branching
Normal file
|
@ -0,0 +1,53 @@
|
|||
title = Parallelism
|
||||
cards = checkout commit-auto
|
||||
|
||||
[description]
|
||||
|
||||
Did you know that creating parallel timelines is perfectly legal and safe? It's true!
|
||||
|
||||
Can you find out when things went wrong in this zoo, and create a parallel universe where everyone is happy?
|
||||
|
||||
[setup]
|
||||
|
||||
mkdir cage
|
||||
echo "Looks very hungry." > cage/lion
|
||||
|
||||
echo "A small child.
|
||||
It really loves cats!" > child
|
||||
git add .
|
||||
git commit -m "The beginning"
|
||||
|
||||
echo "It's holding a lollipop." >> child
|
||||
git commit -am "The child buys something"
|
||||
|
||||
mv child cage
|
||||
git add .
|
||||
git commit -m "The child climbs somewhere"
|
||||
|
||||
git rm cage/child
|
||||
echo "Looks happy. :)" > cage/lion
|
||||
git add .
|
||||
git commit -m "Oh no"
|
||||
|
||||
echo "It's sleeping." > cage/lion
|
||||
git add .
|
||||
git commit -m "Nap time!"
|
||||
|
||||
git checkout --detach
|
||||
git branch -d main
|
||||
|
||||
[win]
|
||||
|
||||
# Is the child still there?
|
||||
git ls-tree --name-only -r HEAD | grep child
|
||||
|
||||
# Is the lion not hungry?
|
||||
git show HEAD:cage/lion | grep -v "very hungry"
|
||||
|
||||
[congrats]
|
||||
|
||||
Whew, good job! This seems like a *much* better outcome.
|
||||
|
||||
Feel free to add more parallel timelines, or make them longer.
|
||||
|
||||
If you're ready, our next mission is already waiting...
|
Loading…
Add table
Add a link
Reference in a new issue