At the end of the day, I'm manually running this command before committing to know whether the file actually changed or it's just a line reorder. Maybe I'll set up a git hook for it.
diff -wB <(sort file.txt) <(git show HEAD:file.txt | sort -)
This command compares the file in the working directory to the file in the last commit of your branch without taking the line order into account.
In my case, I use -w
and -B
, to ignore blank spaces and lines which the program also adds. From man diff
:
-w, --ignore-all-space ignore all white space -B, --ignore-blank-lines ignore changes whose lines are all blank