Work on the intro and the index chapter

This commit is contained in:
blinry 2021-01-11 19:16:35 +01:00
parent 4910e4d566
commit 8d333ce56a
31 changed files with 327 additions and 185 deletions

View file

@ -1,31 +0,0 @@
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

@ -1,44 +0,0 @@
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...

View file

@ -1,20 +0,0 @@
title = Cloning a repo
cards = clone commit-auto pull push
[description]
Get your friend's repo using clone, change something, push it back.
[setup]
rm -rf .git
[setup friend]
echo hi > file
git add .
git commit -m "Initial commit"
[win friend]
test "$(git show main:file)" != hi

41
levels/intro/copies Normal file
View file

@ -0,0 +1,41 @@
title = Making copies
cards =
[description]
One month later, you're working on an essay about cats.
You've started making backup copies of your essay regularly - you can look at them by clicking on them!
Your current version, essay4.txt, needs one more line
[congrats]
Okay, this works. 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 copies back and forth doesn't seem ideal. Let's look at another way to do this!
[setup]
rm -rf .git
echo "~ Why cats are the best pets ~
(I still need to write this.)" >> essay1.txt
echo "~ Why cats are the best pets ~
- They live longer than goldfish." >> essay2.txt
echo "~ Why cats are the best pets ~
- They live longer than goldfish.
- Their little paws are super cute." >> essay3.txt
cp essay3.txt essay4.txt
[win]
# Add two more lines to essay4.txt!
test "$(cat essay4.txt | wc -l )" -ge 6

39
levels/intro/git Normal file
View file

@ -0,0 +1,39 @@
title = Enter the time machine
cards = init commit-auto checkout
[description]
Another month later, you're woking on an essay about tardigrades!
But this time, a friend has borrowed you a time machine!
It's called "Git", and it's very shiny.
[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 the time machine!
test -d .git
# Make a snapshot of your essay (a "commit")
test -d .git && git rev-parse HEAD
# Add another line to the essay.
test "$(cat essay.txt | wc -l)" -ge 5
# And make a second commit!
git rev-parse HEAD^ && test "$(git show HEAD:essay.txt | wc -l)" -ge 5
[congrats]
Nice! You can now travel between those two snapshots using `git checkout` - try it, and look at the essay in each commit!
You can also make some additional commits. When you feel comfortable, click on "Next Level".

View file

@ -1,24 +0,0 @@
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!

View file

@ -1,53 +0,0 @@
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

View file

@ -1,26 +1,26 @@
title = Working together
cards = pull commit-auto push
cards = clone checkout commit-auto pull 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`!
A friend has asked you to help with an essay about hobbies! She has already started to write a list, and started tracking it with her own time machine!
[congrats]
"Thanks, these are some really nice hobbies! Hope we can do that together soon!"
You're still pretty confused by everything that's going on. The next day, you decide to enroll in time travel school!
[setup]
rm -rf .git
[setup friend]
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
@ -30,10 +30,16 @@ git commit -m "Added two hobbies"
[win]
# Help her by adding at least two more items to the list!
# Get a copy of her timeline using `git clone`!
test -d .git
# Add at least two more items to the list!
test "$(cat hobbies.txt |wc -l)" -ge 6
# Commit your result.
test "$(git show main: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!
# And use `git push` to send it to your friend!
test "$(git show main:hobbies.txt |wc -l)" -ge 6

View file

@ -1,28 +0,0 @@
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")

44
levels/intro/risky Normal file
View file

@ -0,0 +1,44 @@
title = A normal day
cards =
[description]
You're working on an essay about goldfish! Your current version is already quite nice, but needs a bit more work.
[congrats]
Suddenly, your cat jumps on your keyboard, deletes what you've written, and runs away! Oh no. :( Just look at it now! All your hard work, destroyed!
You decide to be more careful in the future.
(Click "Next Level" as soon as you're ready!)
[setup]
rm -rf .git
echo "~ Why are the best pets ~
- They are pretty.
- They don't pee on the carpet.
- They don't make any noise." >> essay.txt
echo "Your cat is sitting next to you, watching you intensely.
It's small, black, and very cute!" > cat
[actions]
test "$(cat essay.txt | wc -l )" -ge 7 && echo "~ Why goldfish are the best pets ~
- asdijwrlj
- they
- are
- delicious
- adfkafkasdufyasfiudasd" > essay.txt && rm -f cat
[win]
# Add two more lines to essay.txt!
test "$(cat essay.txt | wc -l )" -ge 7

View file

@ -1,5 +1,4 @@
motivation
setup
checkout
restore
first-remote
risky
copies
git
remote

View file

@ -1,34 +0,0 @@
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

View file

@ -1,23 +1,35 @@
title = Nice to meet you!
cards = config-name config-email
title = Welcome to time travel school!
cards = config-name commit-auto checkout
[description]
Introduce yourself using
git config --global user.name Firstname
git config --global user.email "your@mail.com"
Your time travel teacher welcomes you: "Hello there! Wanna tell us your name?"
[setup]
git config --global user.name "You"
echo "~ Why do you want to learn how to use time machines? ~
[ ] To make sure that my cat doesn't eat my homework.
[ ] So I don't have to keep copies of all my essays.
[ ] To collaborate with other time travel students.
[ ] Other, please specify:" > form
[actions]
test "$(git config user.name)" != "You" && hint "Hey $(git config user.name), nice to meet you!"
test "$(git config user.name)" != "You" && hint "Hey $(git config user.name), welcome to time travel school!"
[win]
# Have a name configured.
# Introduce yourself.
test "$(git config user.name)" != "You"
# Have an email address configured.
test "$(git config user.email)" != "you@time.agency"
# Fill out the enrollment form, and commit it!
git show main:form | grep '\[x\]'
[congrats]
"We're glad to have you! See how the commit now includes your name?
Git can help you fix problems in the past! It allows you to collaborate with other students of time travel! It's really powerful, and it's really popular! I'll see you for your first lesson tomorrow!"