That approach is not the best engineering approach and will take up a lot of time for little value - itās best practise to run some Virtual machine technology on your PC so that you can ran 2 or more different versions as the same time: each with their own code base+database.
They also allow you to create āinstant snapshotsā - which you can roll back to very easily: which again makes trouble-shooting and experimenting easier.
People use docker or VMWare type tools for that.