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
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"

View file

@ -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"

View file

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