Very simple if you did it right.
If you running for example 2.4 you will find all updated files for v2.4.1 & v2.4.2 so you can compare them with you files and migrate your changes.
You can use something like this will help you well:
1- For CSS it will easy and good practice if you added your changes from admin panel
2- For templates it will be nice if you make a copy from the default theme and rename it like “my_theme” and add “my_theme” as a new theme from admin panel. to save the default and all changes will be in your own custom theme and with any new release you can make the default theme as the default theme till you migrate the new changes to your “my_theme”
3- For JS/PHP it will be good to make new files and leave the core files with no changes at all. and you can include JS easily from the templates in your theme “my_theme” & PHP files can be included easily in core PHP files.