Polish branches chapter

This commit is contained in:
blinry 2021-01-13 16:26:48 +01:00
parent 80c50bdc81
commit be45b82e41
18 changed files with 231 additions and 191 deletions
levels/branches

81
levels/branches/reorder Normal file
View file

@ -0,0 +1,81 @@
title = Moving branches around
cards = checkout commit-auto merge reset-hard
[description]
One of your colleagues messed up here, and put the branches in the wrong timelines!
You could delete and re-create these branches - but you can also directly move them to different commits, using `git reset --hard`.
The donut branch is in the right place, but the timeline is still incomplete.
[setup]
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 baguette branch?
git show baguette:you | grep "You ate.*baguette"
# Did you drink a coffee on the coffee branch?
git show coffee:you | grep "You drank.*coffee"
# Did you eat a donut on the donut branch?
git show donut:you | grep "You ate.*donut"
[actions]
test "$(git rev-parse HEAD^)" = "$(git rev-parse donut)" && hint "Remember to checkout the blue branch tag when you want it to grow with the timeline."