9

-n works as a grep argument to display the line number, but -H doesn't for filename. I think it is because git diff doesn't by default output filename for each changed line. As I was typing, I considered another option to display multiple lines and it solved my immediate problem, but would still like to know the solution to display the actual filename.

[michael@bigbox www]$ git diff | grep -n -H "this->config"
(standard input):614:-        $config=json_decode($this->config,true);
[michael@bigbox www]$

1 Answer 1

11

I’m not sure you can show both the filename and the changed line in a single command, but the following will list all files where a line containing this->config has changed:

git diff --name-only -G"this->config"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.