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

31
levels/unused/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...

20
levels/unused/clone Normal file
View file

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

27
levels/unused/commit Normal file
View file

@ -0,0 +1,27 @@
title = Make a commit \o/
cards = add reset checkout commit
[description]
For practice, make a commit where all files contain an "x"!
[setup]
echo a > a
echo x > b
echo x > c
git add .
git commit -m "Initial commit"
echo x > a
echo b > b
git add b
echo c > c
[win]
# File a contains "x" in the last main commit.
test "$(git show main:a)" = x
# File b contains "x" in the last main commit.
test "$(git show main:b)" = x
# File c contains "x" in the last main commit.
test "$(git show main:c)" = x

26
levels/unused/commit-a Normal file
View file

@ -0,0 +1,26 @@
title = Make a commit, but faster!
cards = add reset checkout commit commit-a
[description]
There is a time-saving trick, where instead of a plain `git commit`, you can use
git commit -a
This will automatically add all changes you made to local files! Very convenient.
[setup]
echo a > a
echo b > b
echo c > c
git add .
git commit -m "Initial commit"
echo x > a
echo x > b
echo x > c
[win]
# Make a commit where all files contain "x".
test "$(git show main:a)" = x && test "$(git show main:b)" = x && test "$(git show main:c)" = x

14
levels/unused/init Normal file
View file

@ -0,0 +1,14 @@
title = Welcome!
cards = init
[description]
[setup]
rm -rf .git
[win]
# Again, initialize your time machine!
test -d .git

28
levels/unused/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")

23
levels/unused/who-are-you Normal file
View file

@ -0,0 +1,23 @@
title = Nice to meet you!
cards = config-name config-email
[description]
Introduce yourself using
git config --global user.name Firstname
git config --global user.email "your@mail.com"
[setup]
[actions]
test "$(git config user.name)" != "You" && hint "Hey $(git config user.name), nice to meet you!"
[win]
# Have a name configured.
test "$(git config user.name)" != "You"
# Have an email address configured.
test "$(git config user.email)" != "you@time.agency"