gitversion-controlgrepgit-grep

Find out when the last use of variable was removed from the git repo


I have an unused variable in my code, and I wonder how things got to be this way. Can I use git grep (or something else) to find out easily?


Solution

  • git log -Svarname
    

    where varname is the name your variable.

    See https://git-scm.com/docs/git-log#git-log--Sltstringgt:

    Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file.