>_ IzzyLab

Hands-on task

This task is step 4 of the course “Git: first commits”

History: git log

easy~4 min

The /root/shop repository already has a history of several commits. Find the commit that added card payments and write its short hash to /root/answer.txt.

A short hash is the first 7 characters of the commit's identifier, for example 3f9c2ab.

What you'll practise:
  • git log
  • git log --oneline
  • commit hash
  • git show

Topic breakdown

Every commit has a hash — a unique identifier of 40 characters (digits and the letters a–f). You can refer to a commit by it: view it, compare it, revert it. Usually the first 7 characters are enough — that's the short hash.

git log shows the history from newer commits to older ones: hash, author, date and message. The --oneline flag prints one line per commit:

$ git log --oneline
8d1e4f0 Update README
c72a9b3 Add tests
1a0f5e2 First commit

And git show hash shows exactly what changed in a single commit.

Git opens long output in a viewer: you scroll with the arrow keys and the space bar, and leave with the q key.

What's checked

  1. File /root/answer.txt created
  2. The answer is the hash of the right commit

What it looks like