2020-10-29 15:55:10 +01:00
|
|
|
title = Branching out
|
2020-10-29 20:02:43 +01:00
|
|
|
cards = checkout commit-auto merge reset-hard
|
2020-10-22 16:19:22 +02:00
|
|
|
|
2020-10-22 14:01:08 +02:00
|
|
|
[description]
|
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
You can use these little blue labels to give names to different timelines! This makes it easier to remember what happened where.
|
2020-10-22 14:01:08 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
One of your colleagues messed up here - can you help reordering the branches correctly using the "reset" card?
|
2020-10-22 17:27:54 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
When you do commits or merges while you're on a branch, the branch will grow with you. Try that while you eat that donut.
|
2020-10-22 17:27:54 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
Finally, merge all timelines together, in a way so that the "main" branch points to the result. That's base reality!
|
2020-10-22 14:01:08 +02:00
|
|
|
|
|
|
|
[setup]
|
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
echo "A friendly old lady.
|
|
|
|
Sells delicious baguettes." > mary
|
|
|
|
|
|
|
|
echo "A rebellious teenager.
|
|
|
|
Sells good coffee." > larry
|
|
|
|
|
|
|
|
echo "A snail. Literally a snail.
|
|
|
|
Sells donuts with an unspecified, slimy filling." > gary
|
|
|
|
|
|
|
|
echo "You do not have a baguette.
|
|
|
|
|
|
|
|
You do not have coffee.
|
2020-10-22 14:01:08 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
You do not have a donut." > you
|
2020-10-22 14:01:08 +02:00
|
|
|
|
|
|
|
git add .
|
2020-10-29 15:55:10 +01:00
|
|
|
git commit -m "The Beginning"
|
2020-10-22 14:01:08 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
git checkout -b coffee
|
|
|
|
echo "You have 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 15:55:10 +01:00
|
|
|
git commit -m "You buy a baguette"
|
|
|
|
|
|
|
|
echo "You ate a baguette.
|
2020-10-22 14:01:08 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
You do not have coffee.
|
|
|
|
|
|
|
|
You do not have a donut." > you
|
2020-10-22 17:27:54 +02:00
|
|
|
git add .
|
2020-10-29 15:55:10 +01:00
|
|
|
git commit -m "You eat the baguette"
|
|
|
|
|
|
|
|
git checkout -b baguette main
|
|
|
|
echo "You do not have a baguette.
|
|
|
|
|
|
|
|
You have coffee.
|
2020-10-22 14:01:08 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
You do not have a donut." > you
|
2020-10-22 14:01:08 +02:00
|
|
|
git add .
|
2020-10-29 15:55:10 +01:00
|
|
|
git commit -m "You buy some coffee"
|
2020-10-22 14:01:08 +02:00
|
|
|
|
2020-10-29 15:55:10 +01:00
|
|
|
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"
|
|
|
|
|
|
|
|
git checkout --detach main
|
2020-10-22 14:01:08 +02:00
|
|
|
|
|
|
|
[win]
|
|
|
|
|
2020-12-22 17:04:01 +01:00
|
|
|
# Did you eat a baguette on the main branch?
|
|
|
|
git show main:you | grep "You ate.*baguette"
|
|
|
|
|
|
|
|
# Did you drink a coffee on the main branch?
|
|
|
|
git show main:you | grep "You drank.*coffee"
|
|
|
|
|
|
|
|
# Did you eat a donut on the main branch?
|
|
|
|
git show main:you | grep "You ate.*donut"
|
|
|
|
|
|
|
|
[actions]
|
|
|
|
|
|
|
|
test "$(git rev-parse HEAD^)" = "$(git rev-parse donut)" && hint "Ooops, your branch ref is still on the old commit."
|
2020-10-29 15:55:10 +01:00
|
|
|
|
|
|
|
[congrats]
|
|
|
|
|
|
|
|
Nice! It's often convenient to stay on branches most of the time!
|