I think this question is very general, so sorry for not being specific. When I modify some come code to try something new, whatever the project or language, I may have to revert back to previous Git commits if it all fails. But in the process of making these uncertain modifications (let's call them X), I also make some nice corrections or additions (let's call them Y) that I want to keep.
Is there a clever way to separate X and Y, so that at the end of the day I can keep Y and discard X?
Here's what I do: