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

View file

@ -0,0 +1,39 @@
title = Moving through time
cards = checkout commit-auto
[description]
The yellow boxes are frozen points in time, we call them "commits"! You can travel between them using the "checkout" card! (Try it!)
The grey panel below shows your current environment - click on an object to inspect or modify it!
Can you find out what happened here? Then, while on the latest commit, fix the problem, and make a new commit!
[setup]
echo "This piggy bank belongs to the big sister.
It contains 10 coins." > piggy_bank
git add .
git commit -m "The beginning"
echo "A young girl with brown, curly hair." > little_sister
git add .
git commit -m "Little sister comes in"
echo "Has 10 coins." >> little_sister
echo "This piggy bank belongs to the big sister.
It is empty." > piggy_bank
git add .
git commit -m "Little sister does something"
git checkout HEAD^^
git branch -df main
[win]
# Restore sisterly peace.
{ git show HEAD:piggy_bank | grep "10 coins"; } && { git show HEAD:little_sister | grep -v "10 coins"; } && { git rev-parse HEAD^^^; }
[congrats]
Wonderful! Now that you're getting familiar with the time machine, let's look at some more complicated situations...