mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-03 19:04:40 +01:00
Add all new levels
This commit is contained in:
parent
8c4c4feeef
commit
812bf48b55
7 changed files with 202 additions and 0 deletions
28
levels/experiments/commit
Normal file
28
levels/experiments/commit
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
title = "fu"
|
||||||
|
|
||||||
|
[description]
|
||||||
|
|
||||||
|
So you've been working on a project for a while, and decide you want to put it in a Git repository.
|
||||||
|
|
||||||
|
Here's how to do it! First, you initialize a new Git repository in your current directory:
|
||||||
|
|
||||||
|
git init
|
||||||
|
|
||||||
|
Then say that you want to record the current state of all files:
|
||||||
|
|
||||||
|
git add .
|
||||||
|
|
||||||
|
And then you make a commit, which gives the current state a description, a date, and your name:
|
||||||
|
|
||||||
|
git commit
|
||||||
|
|
||||||
|
[setup]
|
||||||
|
|
||||||
|
mkdir recipes
|
||||||
|
echo -e "blueberries\nflour" > recipes/blueberry_cake.txt
|
||||||
|
echo -e "water\ncarrots" > recipes/carrot soup.txt
|
||||||
|
echo "Very good recipes!" > README.md
|
||||||
|
|
||||||
|
[win]
|
||||||
|
|
||||||
|
test "$(git rev-parse HEAD^{tree})" = 1e02e3151284d0e22cd9b07ca5c5dbae2f3cb521
|
32
levels/experiments/pull-merge-push
Normal file
32
levels/experiments/pull-merge-push
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
title = A pull and a conflict
|
||||||
|
author = blinry
|
||||||
|
|
||||||
|
[description]
|
||||||
|
|
||||||
|
You want to push your new commits to the server, but someone has already pushed their own changes.
|
||||||
|
|
||||||
|
In this situation, you need to pull first! Try that here - you'll have to resolve a merge conflict. Push your changes afterwards.
|
||||||
|
|
||||||
|
[congrats]
|
||||||
|
|
||||||
|
Good job! Here's some additional info: banana!
|
||||||
|
|
||||||
|
[setup yours]
|
||||||
|
|
||||||
|
echo fu > file
|
||||||
|
git add .
|
||||||
|
git commit -m "Initial commit"
|
||||||
|
git push
|
||||||
|
|
||||||
|
echo fi > file
|
||||||
|
git commit -a -m "Fi is good"
|
||||||
|
|
||||||
|
[setup origin]
|
||||||
|
|
||||||
|
echo fa > file
|
||||||
|
git add .
|
||||||
|
git commit -a -m "Fa is good"
|
||||||
|
|
||||||
|
[win origin]
|
||||||
|
|
||||||
|
test "$(git rev-parse HEAD^1^)" = "$(git rev-parse HEAD^2^)"
|
20
levels/experiments/rebase
Normal file
20
levels/experiments/rebase
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
description = Rebase all branches on top of the main branch, so that the commits are in alphabetical order, and then point the main branch to the top commit.
|
||||||
|
|
||||||
|
[setup]
|
||||||
|
|
||||||
|
git commit --allow-empty -m A
|
||||||
|
git commit --allow-empty -m B
|
||||||
|
git commit --allow-empty -m C
|
||||||
|
|
||||||
|
git switch -c side1 main~1
|
||||||
|
git commit --allow-empty -m D
|
||||||
|
git commit --allow-empty -m E
|
||||||
|
|
||||||
|
git switch -c side2 main~2
|
||||||
|
git commit --allow-empty -m F
|
||||||
|
|
||||||
|
git checkout main
|
||||||
|
|
||||||
|
[win]
|
||||||
|
|
||||||
|
diff <(git log --pretty=%s main) <(echo -e "F\nE\nD\nC\nB\nA")
|
8
levels/experiments/sandbox
Normal file
8
levels/experiments/sandbox
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[setup local]
|
||||||
|
|
||||||
|
git commit --allow-empty -m "1"
|
||||||
|
git commit --allow-empty -m "2"
|
||||||
|
git commit --allow-empty -m "3"
|
||||||
|
git push
|
||||||
|
|
||||||
|
[setup origin]
|
48
levels/intro/motivation
Normal file
48
levels/intro/motivation
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
[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?
|
||||||
|
|
||||||
|
Make a new version (with the number 5) from the last version that's still okay, and add at least two more lines to it!
|
||||||
|
|
||||||
|
[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.)" >> essay_1.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?)" >> essay_2.txt
|
||||||
|
|
||||||
|
|
||||||
|
echo "~ Why goldfish are the best pets ~
|
||||||
|
|
||||||
|
- They are pretty.
|
||||||
|
- They don't pee on the carpet.
|
||||||
|
- They don't make any noise." >> essay_3.txt
|
||||||
|
|
||||||
|
echo "~ Why gldfsh r th bst pts ~
|
||||||
|
|
||||||
|
- Thy r prtty.
|
||||||
|
- Thy dn't p n th crpt.
|
||||||
|
- Thy dn't mk ny ns." >> essay_4.txt
|
||||||
|
|
||||||
|
[win]
|
||||||
|
|
||||||
|
test "$(cat *5.txt | wc -l )" -ge 7 && grep carpet *5.txt
|
35
levels/intro/restore
Normal file
35
levels/intro/restore
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[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 again! :/
|
||||||
|
|
||||||
|
To restore your essay from the last backup, type:
|
||||||
|
|
||||||
|
git restore essay.txt
|
||||||
|
|
||||||
|
To restore an older version, for example, from two backups before the latest one, type:
|
||||||
|
|
||||||
|
git restore -s HEAD~2 essay.txt
|
||||||
|
|
||||||
|
For nostalgic reasons, restore the very first backup you made!
|
||||||
|
|
||||||
|
[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]
|
||||||
|
|
||||||
|
diff essay.txt <(echo "A")
|
31
levels/intro/setup
Normal file
31
levels/intro/setup
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
[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, type:
|
||||||
|
|
||||||
|
git init
|
||||||
|
|
||||||
|
Then, each time you want to make a backup, type:
|
||||||
|
|
||||||
|
git add essay.txt
|
||||||
|
git commit
|
||||||
|
|
||||||
|
Enter a description of what you changed in the editor that opens and click save.
|
||||||
|
|
||||||
|
That way, you've made a backup of the current version of the file. Then add at least two more lines, and make another backup by repeating the add and the commit commands.
|
||||||
|
|
||||||
|
[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]
|
||||||
|
|
||||||
|
test -d .git && git rev-parse HEAD^ && test "$(git show HEAD:essay.txt | wc -l)" -ge 6
|
Loading…
Reference in a new issue