oh-my-git/levels/index/compare

51 lines
1.3 KiB
Text
Raw Permalink Normal View History

title = Step by step
2021-02-04 12:01:58 +01:00
cards = checkout commit-auto
[description]
2021-02-04 12:01:58 +01:00
Welcome to today's lesson! We're going to learn how to make commits with more precision!
Have a look at these two timelines. They have exactly the same outcome. But one of them makes it much easier to figure out what happened.
2021-02-04 12:01:58 +01:00
[win]
Right! Having each change in its own commit makes it easier to understand what's going on! Let's learn how to do that!
[setup]
echo "A small, but heavy glass ball." > ball
echo "A thin book, that's standing upright." > book
echo "A candle, burning with a blue flame." > candle
2021-02-04 12:01:58 +01:00
echo "A smoke detector. It's absolutely silent." > smoke_detector
git add .
git commit -m "The beginning"
git branch -M all-at-once
echo "The ball is now touching the book." > ball
echo "The book has fallen over." > book
echo "The candle has been blown out." > candle
git commit -am "The end"
git checkout HEAD^
git checkout -b step-by-step
echo "The ball is now touching the book." > ball
git commit -am "The ball rolls towards the book"
echo "The book has fallen over." > book
git commit -am "The book falls over"
echo "The candle has been blown out." > candle
git commit -am "The book blows out the candle"
git checkout HEAD~3
[win]
2021-02-04 12:01:58 +01:00
# Pick the timeline that's clearer, and make the next logical change!
git show step-by-step:smoke_detector | grep -v "absolutely silent"