mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-22 20:32:38 +01:00
40 lines
1.2 KiB
Text
40 lines
1.2 KiB
Text
title = Creating branches
|
|
cards = checkout commit-auto branch branch-delete reset-hard
|
|
|
|
[description]
|
|
|
|
You were invited to two parties! At one of them, your favorite band is playing - and the other one is your best friend's birthday party. Where should you go? No worries - as a time travel agent in training, you can go to both parties!
|
|
|
|
To make it easier to tell which timeline is which, you can create time portals! (We call these "branches".)
|
|
|
|
[setup]
|
|
|
|
echo "You wrap the birthday present, and grab your concert ticket." > you
|
|
git add .
|
|
git commit -m "Evening preparations"
|
|
echo "You go to the birthday party!" >> you
|
|
git add .
|
|
git commit -m "Go to the birthday"
|
|
|
|
git checkout HEAD~1
|
|
echo "You go to the concert!" > you
|
|
git add .
|
|
git commit -m "Go to the concert"
|
|
|
|
git checkout HEAD~1
|
|
|
|
git branch -D main
|
|
|
|
[win]
|
|
|
|
# Create a branch called 'birthday' that points to the birthday timeline.
|
|
git show birthday | grep 'to the birthday'
|
|
|
|
# Create a branch called 'concert' that points to the concert timeline.
|
|
git show concert | grep 'to the concert'
|
|
|
|
[congrats]
|
|
|
|
Now you can travel between those branches easily (using `git checkout`) - try it!
|
|
|
|
Your friend is happy that you made it to the birthday party and you also got your concert ticket signed. Yay!
|