I am a data scientist who programs in R, but am relatively new to using version control (yes, I know!) and I am still learning lots about it.
FYI: I use BitBucket and Sourcetree
I understand the general idea behind it - that you commit new updates / features / etc. - and that it acts as a safety net where you can revive features/code that would have otherwise been lost/overwritten, or even reverse your reversals if you decide you were in fact happy with the new code you'd written.
Today, I came to the realisation that I will need to completely rewrite an R script that I have (which I created/built myself - no other collaborators) because the requirements have now changed significantly, and rather than making several changes to the existing code (we're talking around 75.00%), it would probably be better and more efficient to rewrite it in its entirety.
As such, I would like to know the following: what is considered best practice in this case?
Should I create a new branch?
I have only ever used the main/master branch in git (I told you I was new to VCS's) and was thinking that I could do this (create a new branch) and then delete the content from my existing script and begin rewriting it in the same file (in order to preserve the same filename/history when I push the changes to my git repository).
My understanding is that my new changes are branched off of / away from the master branch and, if I am happy, I can/should merge them back into the master branch at the point where I am happy/confident that the changes are good to go - is that correct?
Or should I do something else?
If it is the former (creating a new branch), what might such a new branch typically be called?
I know that I'm not the only person to have ever needed to do a complete code rewrite/rebuild, so would appreciate some advice here.