oh-my-git/levels/changing-the-past/rebase

87 lines
2.1 KiB
Plaintext

title = Rebasing
cards = checkout commit-auto reset-hard rebase
[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.
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.
Again, we want to make that our base reality - the "main" branch should point to that timeline!
[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"
git checkout -b baguette main
echo "You have a baguette.
You do not have coffee.
You do not have a donut." > you
git add .
git commit -m "You buy a baguette"
echo "You ate a baguette.
You do not have coffee.
You do not have a donut." > you
git add .
git commit -m "You eat the baguette"
git checkout -b coffee main
echo "You do not have a baguette.
You have coffee.
You do not have a donut." > you
git add .
git commit -m "You buy some coffee"
echo "You do not have a baguette.
You drank coffee.
You do not have a donut." > you
git add .
git commit -m "You drink the coffee"
git checkout -b donut main
echo "You do not have a baguette.
You do not have coffee.
You have a donut." > you
git add .
git commit -m "You buy a donut"
echo "You do not have a baguette.
You do not have coffee.
You ate a donut." > you
git add .
git commit -m "You eat the donut"
git checkout --detach main
[win]
# Order all tree branches into one and move the main branch ref
{ 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; }
[congrats]
Notice how the other timelines and commits are still there - if anything goes wrong, you can also travel back to them.
It's really hard to actually *destroy* stuff with your time machine.