Parse git log by modified files

Posted by MrUser on Ask Ubuntu See other posts from Ask Ubuntu or by MrUser
Published on 2014-05-28T09:08:50Z Indexed on 2014/05/28 10:05 UTC
Read the original article Hit count: 271

Filed under:
|
|
|

I have been told to make git messages for each modified file all one line so I can use grep to find all changes to that file. For instance:

$git commit -a
     modified: path/to/file.cpp/.h - 1) change1 , 2) change2, etc......

$git log | grep path/to/file.cpp/.h
     modified: path/to/file.cpp/.h - 1) change1 , 2) change2, etc......
     modified: path/to/file.cpp/.h - 1) change1 , 2) change2, etc......
     modified: path/to/file.cpp/.h - 1) change1 , 2) change2, etc......

That's great, but then the actual line is harder to read because it either runs off the screen or wraps and wraps and wraps.

If I want to make messages like this:

$git commit -a
     modified: path/to/file.cpp/.h 
               1) change1 
               2) change2
               etc......

is there a good way to then use grep or cut or some other tool to get a readout like

$git log | grep path/to/file.cpp/.h
     modified: path/to/file.cpp/.h 
               1) change1 
               2) change2
               etc......
     modified: path/to/file.cpp/.h 
               1) change1 
               2) change2
               etc......
     modified: path/to/file.cpp/.h 
               1) change1 
               2) change2
               etc......

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about git