I’m not sure if this is the right way to respond to your question (this UI is weird).
The answer is that refactorings must be broken up into changes which incrementally move toward the desired end-state without breaking anything in the meantime. It’s a skill, but it can be done.
For example, there was a huge refactoring of the extensions system that happened near the end of my time on Chromium. It was done by building up a new framework in a new place in the codebase and slowly moving over feature by feature.