I come across this scenario often. I create new_file.py
and move some or most of the code from old_file.py
to it. After I stage both the files, I need to ensure that I haven't introduced any errors.
If I run git diff
, I am shown the deleted lines in the old file (in red) and the added lines in new file (in green).
If these changes were in a single file, I could pass these options to git diff:
--word-diff
to ensure only the specific variable has been changed--ignore-space-change
to ensure only indentation has changedHow can I pass something similar to --word-diff
or --ignore-space-change
to the git diff?
You can try and comparing directly the two files as they are on the filesystem, as opposed to comparing them against the git index:
git diff --no-index --ignore-space-change --word-diff -- old_file.py new_file.py