I am a regular user of git dag
<sourcefilepath> to check all commits applying on a single source file. You can also do it with gitk <sourcefile>
but I always find git dag
more convenient.
Recently, I had to check the changes made on a specific line of a source file. I started digging into 7 years of commits… and obviously it was time to search for a better option 🙂
Fortunately, git log
is really powerful.
First you can list commits with an impact on a specific function using the -L option. The diff are display immediately which is pretty handy. For example: git log -L:sendTcpRequest:src/evcc/Evcc.cpp
. The -L
option be used for numerous other stuff, please check git log --help
.
This was still listing dozen of diff. The -G
option allows to directly search on all the diffs and list related commit. For example git log -G "flush" Evcc.cpp
was listing me 3 commits with a diff containing the word « flush ».