oh-my-git/levels/time-machine/branches

51 lines
1.2 KiB
Text
Raw Normal View History

2020-10-22 17:27:54 +02:00
title = Parallelism
2020-10-22 16:19:22 +02:00
[description]
2020-10-22 17:27:54 +02:00
In this zoo, we found a some parallel timelines. What's going on here? The ends of the timelines have little tags attached.
2020-10-22 17:27:54 +02:00
Especially the `bad_ending` one needs our attention! Can you travel to the `good_ending` timeline, and make a new commit where everyone involved is happy?
[congrats]
Whew, good job! This seems like a *much* better outcome.
But our next mission is already waiting...
[setup]
git checkout -b bad_ending
mkdir cage
mkdir toy_shop
echo "Looks very hungry." > cage/lion
echo "A small child.
It really loves cats!
It's holding a lollipop." > child
git add .
git commit -m "The beginning"
mv child cage
git add .
git commit -m "The child is curious"
git branch good_ending
git rm cage/child
echo "Looks happy. :)" > cage/lion
2020-10-22 17:27:54 +02:00
git add .
git commit -m "Oh no"
git checkout HEAD~2
git checkout -b boring_ending
mv child toy_shop
git add .
git commit -m "The child is distracted"
git checkout bad_ending
[win]
# Is the child still there, and do we have a commit that's not in bad_ending?
{ git ls-tree --name-only -r good_ending | grep child; } && { test "$(git log good_ending ^bad_ending --oneline | wc -l)" -gt 0; }