Git Stash: For when your boss|clients|life priorities change
I discovered git stash awhile ago and have gotten a lot of use out of it.
Basically, it takes your working changes and stashes them somewhere, reverting back to the HEAD. You can retrieve those changes later like they never went away. This allows you to change branches when you want without committing things.
Since you can have lots of stashes and refer to them by name, you can also try one solution, benchmark it, then try a different one and in the end, only apply the best one.
I've been using it this way for awhile, but today I discovered git stash branch which lets you move your stash to a new branch.
Today I was asked to roll back all my working changes for a release, but keep those changes for the next release. Our priorities changed. In the past I would have done a commit, then made a branch, then rolled back a commit. But with git stash branch I just typed:
1 2 |
git stash git stash branch <newbranchname> |
Done.