Large Refactor At The Command Line
As projects grow patterns that worked early on break and we need to change things to make the project easier to work with, and more welcoming to new developers.
git # [2]
Before you start mucking up a project with wild commands at the terminal check that you have a super clean git status. We may make some mistakes and need a way to undo 100’s files and git makes it really easy if you start with a clean history.
git status
If we are ready to begin work we should see a response like this.
On branch main
nothing to commit, working tree clean
It would also be wise to do this inside of a branch. The minute you try to do something wild in your working branch someone will walk by and ask you to do a five-minute task, but your deep in refactoring and haven’t left yourself a clean way back.
git branch my-big-refactor
grepr # [3]
Time for the meat of this refactor replacing text across our project. I often will pop this bash function into my terminal session and tweak it as needed. This...