The Eclipse IDE has a nice feature that automatically logs file revisions and you can view them anytime by right-clicking on a file and clicking on Compare With
For Visual Studio 2015, 2017, 2019 VSHistory extension: maintains the history of files in your Visual Studio projects every time they are saved. Any saved version can be viewed or a diff with the current version can be displayed