2021-01-07 12:57:31 +01:00
|
|
|
title = Getting the last version
|
|
|
|
cards = checkout-file
|
2020-10-12 20:09:51 +02:00
|
|
|
|
2020-10-06 10:51:12 +02:00
|
|
|
[description]
|
|
|
|
|
2021-01-07 12:57:31 +01:00
|
|
|
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! :/
|
2020-10-06 10:51:12 +02:00
|
|
|
|
2021-01-07 12:57:31 +01:00
|
|
|
But Git is here to help! To discard all changes your cat made, and go back to the version in the last commit, use `checkout`!
|
2020-10-06 10:51:12 +02:00
|
|
|
|
|
|
|
[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]
|
|
|
|
|
2021-01-07 12:57:31 +01:00
|
|
|
# Restore the version from the last commit.
|
|
|
|
cat essay.txt | grep D
|