From 779d03416f780b9d904d7d102b10535e07578f24 Mon Sep 17 00:00:00 2001 From: blinry Date: Tue, 5 Jan 2021 17:14:50 +0100 Subject: [PATCH] Tweaks to "shit-happens", like an ordering --- levels/shit-happens/restore-a-file | 19 ++++++++++--------- .../shit-happens/restore-a-file-from-the-past | 19 +++++++++---------- levels/shit-happens/sequence | 5 +++++ 3 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 levels/shit-happens/sequence diff --git a/levels/shit-happens/restore-a-file b/levels/shit-happens/restore-a-file index b51c108..26450f0 100644 --- a/levels/shit-happens/restore-a-file +++ b/levels/shit-happens/restore-a-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" diff --git a/levels/shit-happens/restore-a-file-from-the-past b/levels/shit-happens/restore-a-file-from-the-past index 17f74be..b51c108 100644 --- a/levels/shit-happens/restore-a-file-from-the-past +++ b/levels/shit-happens/restore-a-file-from-the-past @@ -1,22 +1,21 @@ -title = Restore a deleted file -cards = checkout +title = Restore a file from the past +cards = checkout checkout-from commit [description] -Oops - you deleted the "essay" file, which you worked on all night! +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: -Luckily, Git is here to help! You can use `git checkout` to restore the file! + git checkout [commit] [file] [setup] -echo important > essay +echo "good version" > essay git add . git commit -m "Initial commit" -echo "important content" > essay -git commit -am "Improve essay" -rm essay +echo "bad version" > essay +git commit -am "\"Improve\" essay" [win] -# Make changes to all three files, and add all of them to the index. -test "$(cat essay)" = "important content" +# Get the first version of your essay, and make a new commit with it. +test "$(git show main:essay)" = "good version" diff --git a/levels/shit-happens/sequence b/levels/shit-happens/sequence new file mode 100644 index 0000000..663d5d9 --- /dev/null +++ b/levels/shit-happens/sequence @@ -0,0 +1,5 @@ +restore-a-file +restore-a-file-from-the-past +bad-commit +pushed-something-broken +reflog