Searching through history code
Sometimes it is not enough; by just looking through the commit messages in the history, you may want to know which commits touched a specific method or variable. This is also possible using git log
. You can perform a search for a string, for example, a variable or method, and git log
will give you the commits, adding or deleting the string from the history. In this way, you can easily get the full commit context for the piece of code.
Getting ready
Again, we will use the JGit repository with the master branch pointing to b14a939
:
$ git checkout master && git reset --hard b14a939
How to do it...
We would like to find all the commits that have changes made to lines that contain the method "isOutdated"
. Again, we will just display the commits on one line each then we can check them individually later:
$ git log -G"isOutdated" --oneline f32b861 JGit 3.0: move internal classes into an internal subpackage c9e4a78 Add isOutdated method to DirCache 797ebba...