"git stash" is my new best friend

This is not gonna be any news for a lot of people out there, but I recently discovered the beauty of the git command stash. And even though I feel a little embarrassed about the fact that I did not discover it earlier, I decided to post a quick note about it.

Before I begin, I’d like to explain that in my main project, I am currently the sole developer. That often made me think of git as more of a deployment tool, then the version control application that it is. And because of that, I didn’t feel I necessarily had to learn everything git had to offer.

Now back to git stash. It is the saviour at those moments when you are in the middle of a task and someone comes knocking on your shoulder with something veeery urgent. You know that the thing you are in the middle of will take some time to finish and you don’t want to commit something half finished that will end up breaking the app. So what do you do? Why, you stash it of course. By simple writing

$ git stash

you stove away the changes you have done so far and you are left with how the branch looked like before you started. Now you can switch to whatever existing branch you want or create a new one, fix that veeery urgent thing and commit it just like you normally do.

Once you are done, just switch back to the branch you were working on and type

$ git stash apply

and you can continue working from were you left off.

If I only knew earlier…. well, serves me right for not go looking for it I guess.