Alice: basic branching
Reading the chapter again, Alice understands she has to enhance the vocabulary of the descriptions. But she also wants to keep developing the story, separating both tasks.
Lab
so she creates a *branch* to undertake that task.git status
git branch # show branches
git b█████ vocabulary-chapter-01 # create new branch
git status
git branch # show branches
git c███████ vocabulary-chapter-01 # move HEAD to the new branch
git status
git status
git branch # show branches
git b█████ vocabulary-chapter-01 # create new branch
git status
git branch # show branches
git c███████ vocabulary-chapter-01 # move HEAD to the new branch
git status
Solution
git status
git branch
git branch vocabulary-chapter-01
git status
git branch
git checkout vocabulary-chapter-01
git status
- Our artist wants to check where HEAD is pointing to:
cat .git/HEAD
cat .git/refs/heads/vocabulary-chapter-01 # It contains the same value than main!
cat .git/refs/heads/main
- Alice will replace the appearance of the word beach with the much more beautiful sand
cat chapter-01.md | grep beach
sed -z -i 's/beach/sand/' chapter-01.md
cat chapter-01.md | grep -e sand -e beach -e shore -e border
git add chapter-01.md
git commit -m "Replacing beach for sand"
git log
- Probably she will also change other words, but right now she wants to modify an important point of the story. So she moves
HEAD
to the main branch
git checkout main
cat chapter-01.md | grep -e sand -e beach # No sand, here
git log
- The saviour of Tim has actually an interesting profession, much more evocative than a simple kind stranger
sed -i 's/a kind stranger/the lighthouse keeper/' chapter-01.md
cat chapter-01.md
git add chapter-01.md
git commit -m "Introducing the lighthouse keeper"
git log