Tweaks to "shit-happens", like an ordering

This commit is contained in:
blinry 2021-01-05 17:14:50 +01:00
parent 12ea306302
commit 779d03416f
3 changed files with 24 additions and 19 deletions
levels/shit-happens

View file

@ -1,21 +1,22 @@
title = Restore a file from the past
cards = checkout checkout-from commit
title = Restore a deleted file
cards = checkout
[description]
Here's a similar problem: you really liked the essay from the very first commit, and want to have it back! Well, checkout can also restore things from older commits, Here's how:
Oops - you deleted the "essay" file, which you worked on all night!
git checkout [commit] [file]
Luckily, Git is here to help! You can use `git checkout` to restore the file!
[setup]
echo "good version" > essay
echo important > essay
git add .
git commit -m "Initial commit"
echo "bad version" > essay
git commit -am "\"Improve\" essay"
echo "important content" > essay
git commit -am "Improve essay"
rm essay
[win]
# Get the first version of your essay, and make a new commit with it.
test "$(git show main:essay)" = "good version"
# Restore the essay to contain "important content"
test "$(cat essay)" = "important content"