2020-10-22 17:27:54 +02:00
title = Rebasing
2020-10-27 12:16:33 +01:00
cards = checkout commit-auto reset-hard rebase
2020-10-22 16:19:22 +02:00
2020-10-22 14:01:08 +02:00
[description]
Okay - turns out that saving time in the morning by utilizing parallel universes is against the regulations of the International Time Travel Association. You'll have to do your tasks in sequence after all.
2020-10-29 20:02:43 +01:00
See the "rebase" card? When you drag it to a commit, it will copy the events in your current timeline after the specified one! This way, make a clean, linear timeline where you visit all three shops.
2020-10-22 17:27:54 +02:00
2020-10-29 20:02:43 +01:00
Again, we want to make that our base reality - the "main" branch should point to that timeline!
2020-10-22 14:01:08 +02:00
[setup]
echo "You do not have a baguette.
You do not have coffee.
You do not have a donut." > you
git add .
git commit -m "The Beginning"
2021-03-04 10:07:35 +01:00
git checkout -b baguette main
2020-10-22 14:01:08 +02:00
echo "You have a baguette.
You do not have coffee.
You do not have a donut." > you
git add .
2020-10-29 20:02:43 +01:00
git commit -m "You buy a baguette"
echo "You ate a baguette.
You do not have coffee.
You do not have a donut." > you
2020-10-22 14:01:08 +02:00
git add .
2020-10-29 20:02:43 +01:00
git commit -m "You eat the baguette"
2020-10-22 14:01:08 +02:00
2021-03-04 10:07:35 +01:00
git checkout -b coffee
2020-10-22 14:01:08 +02:00
echo "You do not have a baguette.
You have coffee.
You do not have a donut." > you
git add .
2020-10-29 20:02:43 +01:00
git commit -m "You buy some coffee"
echo "You do not have a baguette.
You drank coffee.
You do not have a donut." > you
2020-10-22 14:01:08 +02:00
git add .
2020-10-29 20:02:43 +01:00
git commit -m "You drink the coffee"
2020-10-22 14:01:08 +02:00
git checkout -b donut main
echo "You do not have a baguette.
You do not have coffee.
You have a donut." > you
git add .
2020-10-29 20:02:43 +01:00
git commit -m "You buy a donut"
echo "You do not have a baguette.
You do not have coffee.
You ate a donut." > you
2020-10-22 14:01:08 +02:00
git add .
2020-10-29 20:02:43 +01:00
git commit -m "You eat the donut"
git checkout --detach main
2020-10-22 14:01:08 +02:00
[win]
2021-01-14 11:43:45 +01:00
# Order all tree branches into one and move the main branch ref
2020-10-29 20:02:43 +01:00
{ git show main:you | grep "You ate.*baguette"; } && { git show main:you | grep "You drank.*coffee"; } && { git show main:you | grep "You ate.*donut"; } && { test "$(git log main --oneline | wc -l)" -eq 7; }
2020-10-22 17:27:54 +02:00
[congrats]
Notice how the other timelines and commits are still there - if anything goes wrong, you can also travel back to them.
2020-10-29 20:02:43 +01:00
It's really hard to actually *destroy* stuff with your time machine.