Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't believe there's anything built-in for this. It's made tricky by the fact that it's rare for a single line to change several times without the rest of the file changing substantially too, so you'll tend to end up with the line numbers changing a lot.</p> <p>If you're lucky enough that the line always has <em>some</em> identifying characteristic, e.g. an assignment to a variable whose name never changed, you could use the regex choice for <code>git blame -L</code>. For example:</p> <pre><code>git blame -L '/variable_name *= */',+1 </code></pre> <p>But this only finds the <em>first</em> match for that regex, so if you don't have a good way of matching the line, it's not too helpful.</p> <p>You could hack something up, I suppose. I don't have time to write out code just now, but... something along these lines. Run <code>git blame -n -L $n,$n $file</code>. The first field is the previous commit touched, and the second field is the line number in <em>that</em> commit, since it could've changed. Grab those, and run <code>git blame -n $n,$n $commit^ $file</code>, i.e. the same thing starting from the commit before the last time the file was changed.</p> <p>(Note that this will fail you if the last commit that changed the line was a merge commit. The primary way this could happen if the line was changed as part of a merge conflict resolution.)</p> <p>Edit: I happened across <a href="http://git.661346.n2.nabble.com/In-depth-git-blame-td6082521.html" rel="noreferrer">this mailing list post</a> from March 2011 today, which mentions that <code>tig</code> and <code>git gui</code> have a feature that will help you do this. It looks like the feature has been considered, but not finished, for git itself.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload