Git Workshop
POSTS

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

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

    Quick access

    1. Introduction
    2. Alice: repo initialization
    3. Alice: first commits
    4. Alice: moving through the timeline
    5. Alice: basic branching
    6. Alice: merging without conflicts
    7. Alice: merging with conflict resolution
    8. Alice: tagging
    9. Bob: cloning repositories
    10. Bob: pushing to origin
    11. Alice: merging and log format
    12. Alice: centralized repository creation
    13. Bob: pulling
    14. Bob: recovering from errors with the reference log
    15. Bob finds the author of a typo
    16. Alice: amending commits
    17. Alice: history simplification
    18. Alice: cherry picking changesets
    19. Git Workshop Lab
    © Git Workshop 2024