Skip to content

Haiku


Setup

This project contains a single file - haikus.txt - a collection of Haikus (1) written by you. It starts with your first Haiku, Bugs .

  1. A Haiku is a traditional Japanese poem consisting of three phrases with the following structure

    5 syllables
    7 syllables
    5 syllables
    

    Technically, there's more to it than that. But we'll stick with this loose definition since you're just here to learn Git.

cd path/to/parent/dir/
mkdir haiku && cd haiku
git init

echo "Bugs crawl through my code" > haikus.txt
echo "Destroying my work" >> haikus.txt
echo "I will fumigate" >> haikus.txt

git add haikus.txt
git commit -m "Completed Haiku: Bugs"

After completing your first Haiku, you begin work on a second one named Sunlight ☀.

echo "" >> haikus.txt
echo "I yearn for sunlight" >> haikus.txt
echo "But here I code in the dark" >> haikus.txt

Clearly, you're still searching for that final phrase to complete your masterpiece. However, you notice a bug in your Bugs Haiku (lol, the irony 😆). The second line has 5 syllables instead of the required 7!

State of things

haiku/
  haikus.txt
bill@gates:~$ git status
On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   haikus.txt
bill@gates:~$ git log --oneline
0770486 (HEAD -> main) Completed Haiku: Bugs

Challenge

Create a new branch named bug-fix for fixing your Bugs Haiku. Once you've got it fixed, commit the change and merge it into main. Then proceed to finish and commit your second Haiku, Sunlight.


See the solution