Search code examples
giteclipsesearchcommitegit

Eclipse Git search text changed files


Is it a way to search for commits in which files have been changed (code removed or added) using text search?

For example: I have connected to my teams repositorie and now i can see the history of commits. I want to search a commit, in which the line "isGlossaryTermUsed" has changed (added or deleted). I know that i can search it using "search tool", but only if there is such line in code and with this way i cant see what changes the commiter added or deleted.

My english is poor , i hope i formed the question correctly. Thanks in advance.


Solution

  • git log has the -G <pattern> option (docs here) :

    it will list only commits for which the diff contains said pattern.

    You can combine it with other git log options :

    # will list commits along with the files they modified :
    git log --name-only/--name-status
    # will list a file *only* if its diff matches <pattern>
    git log --name-only/--name-status -G <pattern>
    
    
    # will list commits along with the diff (the 'patch') of the commit :
    git log -p
    # will show the diff of file where <pattern> appears
    git log -p -G <pattern>
    

    There is also the -S <pattern> option (docs right next to -G) which adds an additional twist :
    a commit is kept only if the number of times that <pattern> appears changes.

    This second option will keep the commits where the pattern appears or disappears, and ignore commits where it is only moved.


    There may be a field which offers this option somewhere in the GUI for git (I am not familiar with Eclipse git), look for a field which would say -S, -G or pickaxe.