mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-03 19:04:40 +01:00
Polishing the intro chapter
This commit is contained in:
parent
a86fcaadbb
commit
cab8a9837c
7 changed files with 97 additions and 90 deletions
29
levels/intro/commit
Normal file
29
levels/intro/commit
Normal file
|
@ -0,0 +1,29 @@
|
|||
title = Your first commit
|
||||
cards = commit-auto
|
||||
|
||||
[description]
|
||||
|
||||
You can use your time machine to make snapshots of objects around you!
|
||||
|
||||
Here, let's practice this!
|
||||
|
||||
(Your teacher pours some water into a glass.)
|
||||
|
||||
[setup]
|
||||
|
||||
echo "The glass is full of water." > glass
|
||||
|
||||
[win]
|
||||
|
||||
# Make a snapshot of the glass (a "commit")
|
||||
git rev-parse HEAD
|
||||
|
||||
# Change the contents of the glass!
|
||||
! test "$(cat glass)" = "The glass is full of water."
|
||||
|
||||
# And make a second commit!
|
||||
git rev-parse HEAD^ && ! test "$(git show main:glass)" = "The glass is full of water."
|
||||
|
||||
[congrats]
|
||||
|
||||
Nice! You can try making some additional commits. When you feel comfortable, click on "Next Level".
|
|
@ -3,44 +3,40 @@ 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!
|
||||
|
||||
You think that you're almost done - your current version, just needs one more line!
|
||||
This time, you're making a lot of backup copies - you can look at them by clicking on them!
|
||||
|
||||
[congrats]
|
||||
|
||||
Okay, this kind of 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.
|
||||
But you're a bit worried that you'll end up with hundreds of copies of this form, 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.
|
||||
|
||||
You wonder what would be a better way to do this.
|
||||
You can't wait to try these time machines!
|
||||
|
||||
[setup]
|
||||
|
||||
rm -rf .git
|
||||
|
||||
echo "~ Why cats are the best pets ~
|
||||
echo "~ Why I want to learn Git ~
|
||||
|
||||
(I still need to write this.)" >> essay.txt
|
||||
(I still need to write this.)" >> form.txt
|
||||
|
||||
|
||||
echo "~ Why cats are the best pets ~
|
||||
echo "~ Why I want to learn Git ~
|
||||
|
||||
- They live longer than goldfish." >> essay2.txt
|
||||
- So that I can undo mistakes" >> form2.txt
|
||||
|
||||
|
||||
echo "~ Why cats are the best pets ~
|
||||
echo "~ Why I want to learn Git ~
|
||||
|
||||
- They live longer than goldfish.
|
||||
- Their little paws are super cute." >> essay2_final.txt
|
||||
- So that I can undo mistakes
|
||||
- To track my projects over time" >> form2_final.txt
|
||||
|
||||
cp essay2_final.txt essay2_really_final.txt
|
||||
cp form2_final.txt form2_really_final.txt
|
||||
|
||||
[win]
|
||||
|
||||
# Add another line to essay2_really_final.txt!
|
||||
test "$(cat essay2_really_final.txt | wc -l )" -ge 5
|
||||
# Add another line to form2_really_final.txt!
|
||||
test "$(cat form2_really_final.txt | wc -l )" -ge 5
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
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".
|
21
levels/intro/init
Normal file
21
levels/intro/init
Normal file
|
@ -0,0 +1,21 @@
|
|||
title = Enter the time machine
|
||||
cards = init
|
||||
|
||||
[description]
|
||||
|
||||
You've been accepted to time travel school! Yay! It's your first day! Your teacher explains:
|
||||
|
||||
"To do anything with a time machine, you first need to initialize it! Go ahead, try it!"
|
||||
|
||||
[setup]
|
||||
|
||||
rm -rf .git
|
||||
|
||||
[win]
|
||||
|
||||
# Initialize the time machine!
|
||||
test -d .git
|
||||
|
||||
[congrats]
|
||||
|
||||
Nice! See that little owl squirrel that appeared? It will be your companion, and always show you where you are in time!
|
|
@ -3,41 +3,43 @@ 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, and started tracking it with her own time machine!
|
||||
Let's add your name to our list of students!
|
||||
|
||||
I have a copy of it in my time machine - let's work together!
|
||||
|
||||
[congrats]
|
||||
|
||||
"Thanks, these are some really nice hobbies! Hope we can do that together soon!"
|
||||
Welcome to time travel school! :) I'll see you for your first class tomorrow!
|
||||
|
||||
[setup]
|
||||
|
||||
rm -rf .git
|
||||
|
||||
[setup friend]
|
||||
[setup teacher]
|
||||
|
||||
echo "~ Best hobbies ~" > hobbies.txt
|
||||
echo "~ List of current students ~" > students
|
||||
git add .
|
||||
git commit -m "Initial version"
|
||||
|
||||
echo "
|
||||
- Collecting stamps
|
||||
- Looking at clouds" >> hobbies.txt
|
||||
- Sam
|
||||
- Alex" >> students
|
||||
|
||||
git add .
|
||||
git commit -m "Added two hobbies"
|
||||
git commit -m "Added two students"
|
||||
|
||||
[win]
|
||||
|
||||
# Get a copy of her timeline using `git clone`!
|
||||
# Get a copy of your teacher's timeline using `git clone`!
|
||||
test -d .git
|
||||
|
||||
# Add at least two more lines to hobbies.txt
|
||||
test "$(cat hobbies.txt |wc -l)" -ge 6
|
||||
# Add your name to the list of students
|
||||
test "$(cat students |wc -l)" -ge 5
|
||||
|
||||
# Commit your result.
|
||||
test "$(git show main:hobbies.txt |wc -l)" -ge 6
|
||||
test "$(git show main:students |wc -l)" -ge 5
|
||||
|
||||
[win friend]
|
||||
[win teacher]
|
||||
|
||||
# And use `git push` to send it to your friend!
|
||||
test "$(git show main:hobbies.txt |wc -l)" -ge 6
|
||||
# And use `git push` to send it to your teacher!
|
||||
test "$(git show main:students |wc -l)" -ge 5
|
||||
|
|
|
@ -3,11 +3,15 @@ cards =
|
|||
|
||||
[description]
|
||||
|
||||
So you're working on an essay about goldfish! Your current version is already quite nice, but needs a bit more work.
|
||||
So you have decided to apply for time travel school, to learn how to use this time machine called "Git"!
|
||||
|
||||
How exciting!
|
||||
|
||||
You're almost done with the paperwork! You just need to fill in one more reason why you want to learn Git.
|
||||
|
||||
[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!
|
||||
Suddenly, your cat jumps on the table, snatches away the form, and runs away! Oh no. All your hard work, gone!
|
||||
|
||||
You clearly need a better solution.
|
||||
|
||||
|
@ -17,28 +21,22 @@ You clearly need a better solution.
|
|||
|
||||
rm -rf .git
|
||||
|
||||
echo "~ Why goldfish are the best pets ~
|
||||
echo "~ Why I want to learn Git ~
|
||||
|
||||
- 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
|
||||
- So that I can undo mistakes
|
||||
- To track my projects over time" >> form.txt
|
||||
|
||||
[actions]
|
||||
|
||||
test "$(cat essay.txt | wc -l )" -ge 6 && echo "~ Why goldfish are the best pets ~
|
||||
test "$(cat form.txt | wc -l )" -ge 5 && echo "(Has been stolen by your cat.)
|
||||
|
||||
- asdijwrlj
|
||||
- they
|
||||
- are
|
||||
- delicious
|
||||
- adfkafkasdufyasfiudasd" > essay.txt && rm -f cat
|
||||
|
||||
|
||||
|
||||
|
||||
" > form.txt
|
||||
|
||||
[win]
|
||||
|
||||
# Add another line to essay.txt!
|
||||
test "$(cat essay.txt | wc -l )" -ge 6
|
||||
# Add another line to from.txt!
|
||||
test "$(cat form.txt | wc -l )" -ge 5
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
risky
|
||||
copies
|
||||
git
|
||||
init
|
||||
commit
|
||||
remote
|
||||
who-are-you
|
||||
|
|
Loading…
Reference in a new issue