It's a familiar scenario.
You have what you think is a great idea. Implementing it will require gutting your current code base. It may or may not work, it may work but be inefficient, etc.
If it works, you will continue from the new code. If it doesn't, you'll revert to the code prior to the experiment—but you'll keep the experiment around for reference.
You have several options:
- You can commit the experimental code and then either undo that commit or revert to a previous commit.
- You can branch, even after the fact, and then either merge the experimental code (knowing that you will not have conflicts) or just ignore the branch and continue on the trunk.
- If the experiment turned out to have no lasting merit, another option is to simply discard the changes.
Let's leave collaboration and even a remote repository out. Consider the case of working on a solo project with only a local repository.
Are git branches exactly what you need? Is there another facility in git that more closely matches this need? Is branching an overkill and reverting to a prior commit sufficient? Here we assume that you will not continue development on the trunk during the experiment.
What is the workflow recommended in an R&D scenario such as the one described here?