
3 answers
VS Code + Git diff is probably the most common approach for Apex code comparison.
For larger orgs or multiple sandboxes, teams also use org-to-org metadata comparison tools to compare:
- Apex Classes
- Triggers
- Visualforce Pages
- layouts and other metadata before deployment.
We used to compare retrieved metadata manually, but recently started using BOFC for quicker sandbox vs production Apex comparisons:
https://bofc.io/how-to-compare-apex-classes-across-multiple-salesforce-orgs/
Best practice is definitely keeping Git as the source of truth and validating differences before every deployment.