This has to do with my personal life as much as it does programming. While writing a program we often go through many iterations of what we are creating or how to solve individual issues. While, many of these ideas won’t be used in the final program, it is still worth keeping some record of them.
A couple of ways to do this are to use a notebook to work through your ideas. As you change your ideas or come up with new ideas, simply turn the page and start again. This will allow you to keep your old ideas (ideally with dates written by them), while you explore new ideas or solutions. When the notebook is full simply put it on the shelf and start another. Notebooks don’t take up much space and the are relatively cheap to purchase.
I couldn’t begin to list the times that I have run across old notes and they inspired a solution to a new problem that I was having. The same can be true for you. It just takes a bit of a change in how you do things.