Never ever throw your code away!

This is the what I have learned recently. Sometimes you write solution which seems wrong or one that you decide not to use. So you discard your changes, use git reset HEAD and prepare to new approach. This is wrong! I recently learned why.

We were rewritting functionalities from old system to the new one and needed to decide where to place new module. There were two solutions and there were also two of us, so we decided to take different approaches and meet the day after to decide which is best.

My solutions lost, so we decided that we won’t implement it. I checked out changes from my git repository and moved on with second approach. But suddenly it turned out (as it sometimes does), that the first approach was the proper one. Sad thing. I new the solution and could write the code from memory, but lost some time and nerves then. So even when you thing that your new solution is a crap and won’t work. Never ever discard your changes. It is easier to revert a commit or pop from git stash, than to write same solution from the beginning.

Leave a Reply

Your email address will not be published. Required fields are marked *