I spent like 3 hours yesterday deduplicating two functions that were hundreds of lines long and nearly identical. I should probably learn how to use that git command that can diff two files on disk. Luckily I actually enjoy cleaning up code sometimes.
Dunno what OS’s it supports besides Windows but I use Kdiff for random comparisons regularly, I think it works pretty well untill you get to much larger files (20+ MB slows down a lot). The huge file wasn’t code but needed to check output changes for those curious.
I constantly check git comparison with previous versions to see what changed to break things in a build though. Didn’t know there was a way to diff any files in git,should probably just learn to use that one.
I spent like 3 hours yesterday deduplicating two functions that were hundreds of lines long and nearly identical. I should probably learn how to use that git command that can diff two files on disk. Luckily I actually enjoy cleaning up code sometimes.
If you’re using a decent development system, you’ll have an executable called
diff
installed already :)That’s what the
diff
tool is for.If you use VSCode, open both files and then ctrl-shift-P “Compare active file with …”
You’re welcome.
Thank you! I love VS Code
Dunno what OS’s it supports besides Windows but I use Kdiff for random comparisons regularly, I think it works pretty well untill you get to much larger files (20+ MB slows down a lot). The huge file wasn’t code but needed to check output changes for those curious.
I constantly check git comparison with previous versions to see what changed to break things in a build though. Didn’t know there was a way to diff any files in git,should probably just learn to use that one.
Git uses the
diff
binary under the hood (unless you configure it to use something else).You can invoke that directly with
diff file_a.txt file_b.txt
.VS Code’s diff tools are killer. Comparison is smarter than most, and you can edit either file as you go.
And if you want to avoid the Microsoft stank, there’s VS Codium that has been de-Microsoft’d, like Chrome vs. Chromium.
git diff —no-index before.json after.json > showmethegoods.diff
You don’t have to save it to a file but I often do.
You can use a diff app directly such as meld which is free. Highly recommend.