Reorder levels and chapters into a better sequence

This commit is contained in:
blinry 2021-01-07 12:57:31 +01:00
parent 5c1f1ce722
commit c99a35d54f
40 changed files with 128 additions and 288 deletions

31
levels/intro/checkout Normal file
View file

@ -0,0 +1,31 @@
title = Getting the last version
cards = checkout-file
[description]
You've been working on your essay for a while. But - ughh! Now your cat walks over your keyboard and "helps you", so now it's all messed up! :/
But Git is here to help! To discard all changes your cat made, and go back to the version in the last commit, use `checkout`!
[setup]
echo "A" >> essay.txt
git add .
git commit -m "Initial commit"
echo "B" >> essay.txt
git commit -a -m "Improved version"
echo "C" >> essay.txt
git commit -a -m "Even better version"
echo "D" >> essay.txt
git commit -a -m "Marvelous version"
echo "blarg
blaaaargh" > essay.txt
[win]
# Restore the version from the last commit.
cat essay.txt | grep D

View file

@ -0,0 +1,44 @@
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, come back to the latest commit, and fix the problem, using the "commit" card!
[setup]
mkdir room1 room2
echo "A young girl with brown, curly hair." > room1/little_sister
echo "This piggy bank belongs to the big sister.
It contains 10 coins." > room2/piggy_bank
git add .
git commit -m "The beginning"
mv room1/little_sister room2
git add .
git commit -m "Little sister walks over"
echo "Has 10 coins." >> room2/little_sister
echo "This piggy bank belongs to the big sister.
It is empty." > room2/piggy_bank
git add .
git commit -m "Little sister does something"
mv room2/little_sister room1
git add .
git commit -m "Little sister walks back"
git checkout --detach
git branch -d main
[win]
{ git show HEAD:room2/piggy_bank | grep "10 coins"; } && { git show HEAD:room1/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...

39
levels/intro/first-remote Normal file
View file

@ -0,0 +1,39 @@
title = Working together
cards = pull commit-auto push
[description]
A friend has asked you to help with an essay about hobbies! She has already started to write a list, started tracking it in a Git repository. You can get a copy by using `git pull`!
[congrats]
"Thanks, these are some really nice hobbies! Hope we can do that together soon!"
[setup]
echo "~ Best hobbies ~" > hobbies.txt
git add .
git commit -m "Initial version"
git push -u friend main
[setup friend]
git checkout main
echo "
- Collecting stamps
- Looking at clouds" >> hobbies.txt
git add .
git commit -m "Added two hobbies"
[win]
# Help her by adding at least two more items to the list!
test "$(cat hobbies.txt |wc -l)" -ge 6
[win friend]
# When you're done, commit your result and use `git push` to send it to her copy of the repository!
test "$(git show main:hobbies.txt |wc -l)" -ge 6

24
levels/intro/init Normal file
View file

@ -0,0 +1,24 @@
title = Welcome!
cards = init
[description]
Welcome, time agent! Good to see you - we could really use your help with fixing some temporal paradoxes!
Ready to initialize your time machine? Drag the `git init` card into the empty space above it!
[setup]
rm -rf .git
[win]
test -d .git
[congrats]
Oh hey, that's you! :)
The time machine can help you fix problems in the past! It allows you to collaborate with other time agents! It's really powerful, and it's really popular!
Let's get familiar with it! Click on "Next level", as soon as you're ready!

53
levels/intro/motivation Normal file
View file

@ -0,0 +1,53 @@
title = Why Git?
cards = file-copy
[description]
So you've been working on an essay about goldfish. You can look at the backup copies you made by clicking on them!
But look - something went wrong in the latest version of the file! Maybe it has been infected with a vowel-eating virus?
[congrats]
Good that you had that backup, huh?
But you're a bit worried that two weeks from now, you'll have hundreds of copies of your essay, and it will be hard to keep track of all of them.
And especially when working with other people, sending backup copies around doesn't seem ideal.
Let's look at another way to do this. :) Click "Next Level" as soon as you're ready!
[setup]
rm -rf .git
echo "~ Why goldfish are the best pets ~
(I still need to write this.)" >> essay1.txt
echo "~ Why goldfish are the best pets ~
- They don't make any noise.
- They are pretty. (I should probably put this higher in the list?)" >> essay2.txt
echo "~ Why goldfish are the best pets ~
- They are pretty.
- They don't pee on the carpet.
- They don't make any noise." >> essay3.txt
echo "~ Why gldfsh r th bst pts ~
- Thy r prtty.
- Thy dn't p n th crpt.
- Thy dn't mk ny ns." >> essay4.txt
[win]
# Make a new version (with the number 5) from the last version that's still okay
cat essay5.txt | grep carpet
# And add at least two more lines to it!
test "$(cat essay5.txt | wc -l )" -ge 7

28
levels/intro/restore Normal file
View file

@ -0,0 +1,28 @@
title = Looking into the past
cards = checkout-from
[description]
You've been working on your essay for a while. But you're not happy with the changes you've made recently. You want to go back to the version called "Best version"!
No problem, you can use the `checkout` card to restore your essay from an older commit!
[setup]
echo "Initial version" > essay.txt
git add .
git commit -m "Initial commit"
echo "Improved version" > essay.txt
git commit -a -m "Improved version"
echo "Best version" > essay.txt
git commit -a -m "Best version"
echo "Less-good version" > essay.txt
git commit -a -m "Less-good version"
[win]
# For nostalgic reasons, restore the very first backup you made!
diff essay.txt <(echo "Best version")

5
levels/intro/sequence Normal file
View file

@ -0,0 +1,5 @@
motivation
setup
checkout
restore
first-remote

34
levels/intro/setup Normal file
View file

@ -0,0 +1,34 @@
title = A better way
cards = init commit-auto
[description]
One month later, you're woking on an essay about tardigrades!
This time, a friend has recommended that you use the version control system Git to keep backups of your file.
Currently, your directory only contains your essay. To initialize a Git repository in your directory, use the `init` card!
Then, each time you want to make a backup, use the `commit` card!
That way, you've made a backup of the current version of the file.
[setup]
rm -rf .git
echo "~ Why tardigrades are cool ~
- They can survive in space.
- They are resistant to extreme heat and cold." > essay.txt
[win]
# Initialize a Git repository
test -d .git
# And make another commit
test -d .git && git rev-parse HEAD^
# Add at least two more lines.
test "$(git show HEAD:essay.txt | wc -l)" -ge 6