liam.pm

Using git diff to compare files not managed by git

git diff is a useful and familiar tool for inspecting differences between files or directories. It can be used to compare content that is not managed by git using the --no-index flag.

# Compare files
git diff --no-index file1 file2

# Compare directories  
git diff --no-index dir1/ dir2/

Additional options

# Word-level diff instead of line-level
git diff --no-index --word-diff file1 file2

# Show only filenames of different files (useful for directories)
git diff --no-index --name-only dir1/ dir2/