Logo Git

Tips to dig into git log

Publié dans Développement | Marqué avec ,
Share

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.

git dag interface

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 ».

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *