Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
bleeptrack 2021-01-05 17:58:10 +01:00
commit d9a9498277
3 changed files with 24 additions and 19 deletions

View file

@ -1,21 +1,22 @@
title = Restore a file from the past title = Restore a deleted file
cards = checkout checkout-from commit cards = checkout
[description] [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] [setup]
echo "good version" > essay echo important > essay
git add . git add .
git commit -m "Initial commit" git commit -m "Initial commit"
echo "bad version" > essay echo "important content" > essay
git commit -am "\"Improve\" essay" git commit -am "Improve essay"
rm essay
[win] [win]
# Get the first version of your essay, and make a new commit with it. # Restore the essay to contain "important content"
test "$(git show main:essay)" = "good version" test "$(cat essay)" = "important content"

View file

@ -1,22 +1,21 @@
title = Restore a deleted file title = Restore a file from the past
cards = checkout cards = checkout checkout-from commit
[description] [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] [setup]
echo important > essay echo "good version" > essay
git add . git add .
git commit -m "Initial commit" git commit -m "Initial commit"
echo "important content" > essay echo "bad version" > essay
git commit -am "Improve essay" git commit -am "\"Improve\" essay"
rm essay
[win] [win]
# Make changes to all three files, and add all of them to the index. # Get the first version of your essay, and make a new commit with it.
test "$(cat essay)" = "important content" test "$(git show main:essay)" = "good version"

View file

@ -0,0 +1,5 @@
restore-a-file
restore-a-file-from-the-past
bad-commit
pushed-something-broken
reflog