Reading the Diff

  • Green (+) Line added in the new version
  • Red (−) Line removed from old version
  • Yellow (~) Line modified between versions
  • Gray Unchanged context lines

The Origin of Diff

  • Created by Douglas McIlroy at Bell Labs in 1974 for Unix
  • Based on 'longest common subsequence' algorithm (Hunt-McIlroy)
  • Became the foundation for all version control: RCS, CVS, SVN, Git
  • Git uses an optimized variant that handles millions of lines efficiently

Real-World Uses

  • Code review: Spot exactly what changed in a pull request
  • Config auditing: Compare production vs staging environment files
  • Contract review: Find what changed between document versions
  • Debugging: Compare working output vs broken output to isolate bugs
  • Migration testing: Verify API responses match after refactoring

Pro Tips

  • Normalize whitespace first if formatting differences aren't meaningful
  • Sort lines alphabetically before diffing unordered lists (like dependencies)
  • For large files, focus on the colored lines—gray context is unchanged
  • Copy just the changed lines to share specific modifications