A change in my working copy of a Git repository caused an error which mentions a variable foo
and I want to find which files and lines contain a changed line in my working copy which mentions foo
.
If I do git diff path/file
it launches a visual editor, so I can't grep in the shell. Even if that worked, it would omit the name of the file in question.
This answer seems closer to what I want, but it is overstuffed with irrelevant examples using terminology I don't really understand.
I don't want to search through any history (i.e. commits), I want to search for foo
within the changes that I currently made since the last checkout/commit.
"Hey, Git, what did I change which contains foo
and hasn't been committed yet? File names and line numbers, please."
How do I do this?
(I'd also appreciate being able to ask the same question of a visual diff editor, if you happen to know one on Linux which does this.)