Drew Angell
Drew Angell

Reputation: 26056

How to find which commit added a line of code..?

I'm really not even sure how to start with this, but it seems like the sort of thing that should be available.

In a project we have a particular line of code:

if(!current_user_can('administrator'))

I'm trying to figure out how added that line and what issue/commit it belonged to, but I can't seem to figure out a way to do that?

Upvotes: 4

Views: 128

Answers (1)

Mureinik
Mureinik

Reputation: 311308

You can use git blame <file> and navigate to the relevant line of code. Alongside the line itself it will display the commit hash that introduced it and the author of that patch.

Upvotes: 6

Related Questions