I'm looking for some way to automatically save the current state of my code whenever I run some experiment.
But I do not want to pollute the commit history of my main branch with a million automatically-made commits. I was thinking of making a my_experiments
branch, to which I just push the current state of the code whenever an experiment runs.
So I guess what I want is to commit my current code to an experiments
branch, without committing it to my current branch. I still want to retain my uncommitted code on my current branch.
What is the nicest way to do this in git?
Edit
I've been asked to clarify what I want and why.
Sometimes I make a change to the code in order to test something. The changes are typically ugly hacks. Typically the process goes:
- Make hacky change
- Run Code and Save result
- CTRL-Z
- View saved result
I am saving the results of the run, and I would also like to save the state of the code alongside it.
Now I want these "hack" changes to be separate from my normal development cycle - I really just need a record of the state of the code when I made the hack. So rather than have a series of "make hack" "revert-hack" pairs in the commit history of my main branch, I'd like to have all the "hacky" changes committed only to a single "experiments" branch.