DEV Community

Discussion on: How do you make it easier to search through version control for deleted code?

Collapse
 
aghost7 profile image
Jonathan Boudreau • Edited

I actually haven't really run into issues with deleting code instead of commenting it out. Part of it is probably being able to search through the history effectively. There's the basics like being able to go back a blame and being able to see previous versions of a file from your editor. But there's probably some more advanced things which could be used for this specific problem.

The first thing which pops into my mind is git log -p and then search using /<search for something> in the less program (which is the default pager for git). Press n to go to the next match.

You can also use git grep to search through multiple revisions. Lets say you want to search through all the revisions in your current branch - you could run something along the lines of git grep '<search for something>' $(git rev-list HEAD). I've never had to use this particular combination before though, might be overkill.