Skip to content
Aryan Deshmukh

    Git

    The Line git blame Can't See

    git blame tells you who touched a line last. For a line that's already been deleted, it has no answer at all.

    Read the story on Medium

    A deleted line isn't in the file any more, so blame can't see it. It is still in the history, and git can search that.

    You're reading a background job that credits payments, and one line near the top makes you stop. You want to know why it's there, so you do what everyone does. You run git blame.

    The commit is from 2024, with the message "Rescue upload payment info job to execute multiple times which results into duplicate payment entries". You open it expecting to learn about your line. It tells you nothing. That commit wrapped the whole job in a begin/rescue block, and your line moved two spaces to the right.

    The line itself is three years older. blame didn't lie. It answered a question you didn't ask. And that's the mild version of the problem. The serious version is when the line you need isn't in the file any more.

    In this post

    1. 01What blame actually answers
    2. 02git log -S: when did this text start or stop existing?
    3. 03Finding a line that's gone
    4. 04When one change is two commits
    5. 05Which question are you asking?
    6. 06Try it on your own repository

    Continue reading on Medium