oh-my-git/levels/time-machine/reorder

78 lines
1.6 KiB
Text
Raw Normal View History

title = Reordering events
cards = checkout commit-auto reset-hard rebase-interactive cherry-pick
2020-10-22 16:19:22 +02:00
2020-10-20 17:01:54 +02:00
[description]
2020-10-22 22:19:30 +02:00
Oops, looks like there's something messed up here. Can you put the events back into their correct order?
2020-10-29 20:02:43 +01:00
There are two ways to do this: You can drag the "interactive rebase" card to the commit before the one you want to change, then reorder the lines in the file that opens, and save it.
2020-10-22 22:19:30 +02:00
Or you can reset the main tag to the very first commit, and then cherry-pick single commits in the order you want. You have cards for both approaches!
2020-10-20 17:01:54 +02:00
[setup]
2020-10-22 22:19:30 +02:00
echo "You just woke up.
2020-10-20 17:01:54 +02:00
2020-10-22 22:19:30 +02:00
You are NOT wearing underwear.
You are NOT wearing pants.
2020-10-20 17:01:54 +02:00
2020-10-22 22:19:30 +02:00
You are NOT wearing a shirt.
2020-10-20 17:01:54 +02:00
2020-10-22 22:19:30 +02:00
You are NOT wearing shoes." > you
2020-10-20 17:01:54 +02:00
git add .
2020-10-22 22:19:30 +02:00
git commit -m "The Beginning"
echo "You just woke up.
You are NOT wearing underwear.
You are NOT wearing pants.
You are NOT wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on shoes"
echo "You just woke up.
You are NOT wearing underwear.
You are wearing pants.
You are NOT wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on pants"
echo "You just woke up.
You are wearing underwear.
You are wearing pants.
You are NOT wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on underwear"
echo "You just woke up.
You are wearing underwear.
You are wearing pants.
You are wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on shirt"
[win]
{ git log main --oneline | grep -Pz "shoes[\s\S]*pants[\s\S]*underwear"; } && { test "$(git log main --oneline | wc -l)" -eq 5; }
[congrats]
Feel free to reset the level and try the other strategy! Which one do you like better?