Git Workshop
POSTS

Bob finds the author of a typo

Here we will see how Bob is able to trace who introduced a bug in the novel, in the form of a spelling error.

Lab: Alice

  • Alice worked for a lot hours today, and although she is exhausted, she also wants to review the state of the book. So she goes to her repo and gets the updates
cd alice/book
git pull origin main
  • The new chapter written by Bob looks very promising! But Alice notices a problem: John is not living in the lighthouse anymore. So she will help his mate correcting it… but she will inadvertently also introduce another type of error in the sentence:
sed -i "s/the lighthouse/the olt man's home/" chapter-04.md
cat chapter-04.md
  • Job done, add, commit and push… but she is so tired that the commit message is no specially inspired
git add chapter-04.md
git commit -m "Minor change"
git push origin main
  • And, finally, she leaves her working area
cd ../..

Lab: Bob

  • After the weekend, Bob comes back to the old computer continue the development of his chapter
cd bob/book
git pull origin main
  • When he starts editing the text of chapter four, he realizes there is something odd… a typo in a sentence he doesn’t remember to have introduced
cat chapter-04.md | grep "the olt man's home" -C 999
Well... maybe he made a change in the text and doesn't remember it. Or not. He needs to know, so he asks `git` about who wrote each line of the book:
git █████ chapter-04.md \
  | grep -e Alice -e Bob

Solution

git blame chapter-04.md \
  | grep -e Alice -e Bob

  • Ok, mystery solved: so it was a change made by Alice. Bob agrees with the modification, so he just needs to update the wrong word
sed -i "s/the olt/the old/" chapter-04.md
cat chapter-04.md | grep "the old man's home" -C 9999
  • And store it in the common repo
git add chapter-04.md
git commit -m "Fixed typo"
git push origin main
  • Bob exists his working directory
cd ../..

    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