814
submitted 1 day ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 6 points 1 day ago

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.

[-] [email protected] 11 points 1 day ago

If you're using a decent development system, you'll have an executable called diff installed already :)

[-] [email protected] 7 points 1 day ago

That's what the diff tool is for.

[-] [email protected] 4 points 1 day ago

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.

[-] [email protected] 3 points 1 day ago

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.

[-] [email protected] 2 points 1 day ago

git diff —no-index before.json after.json > showmethegoods.diff

You don’t have to save it to a file but I often do.

[-] [email protected] 5 points 1 day ago

If you use VSCode, open both files and then ctrl-shift-P "Compare active file with ..."

You're welcome.

[-] [email protected] 2 points 1 day ago

Thank you! I love VS Code

[-] [email protected] 3 points 1 day ago

VS Code's diff tools are killer. Comparison is smarter than most, and you can edit either file as you go.

[-] [email protected] 4 points 1 day ago

And if you want to avoid the Microsoft stank, there's VS Codium that has been de-Microsoft'd, like Chrome vs. Chromium.

[-] [email protected] 1 points 1 day ago

You can use a diff app directly such as meld which is free. Highly recommend.

this post was submitted on 25 Sep 2024
814 points (97.3% liked)

Programming

17071 readers
414 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS