DEV Community

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

Collapse
 
chilcutt profile image
Kyle Chilcutt

Get really familiar with your version control system! Here's some tips for git:

  1. Always write good, descriptive commit messages, this helps set up later tips.
  2. When you think you know what the commit message contains:
    • git log --grep "<search>" # search logs for string
  3. When you can't find what you want in the log, but know what some of the code said:
    • Use the pickaxe to search content: git log -S"<search>" # search content for string
    • Need something better? Use the pickaxe with a regex: git log -G"<regex>" # search content for regex
  4. When you can't find it in the log, don't know the commit message, but remember where the file was:
    • git log -- <path_to_file> # show logs of file path
  5. When all else fails, get your hands dirty:
    • git log -p # show logs with content