>_ IzzyLab

Hands-on task

This task is step 7 of the course “Git: rewriting and rescuing history”

Find the commit that added a line

medium~7 min

In /root/repo the file config.ini was edited by many commits. At some point someone added the line debug=true to it — now you need to figure out in which exact commit it first appeared. Write the full hash of that commit into the file /root/answer.txt.

What you'll practise:
  • git blame
  • git log -S
  • line history
  • git rev-parse
  • finding a commit

Topic breakdown

To find out which commit last touched a specific line of a file, there's git blame: it annotates each line with an abbreviated hash of its commit, and the -L flag narrows the output to the right range or pattern. The full hash is obtained from the abbreviated one via git rev-parse. An alternative path is the "pickaxe" search git log -S '<line>', which finds commits where the searched text appeared or disappeared; the oldest of them is the moment of first appearance.

What's checked

  1. full hash written
  2. commit of the line's first appearance

What it looks like