Git stash
This isn’t anything new, or anything complex. But it’s handy, and for those who don’t know about it, well, you should know about it.
Have you ever been working on some code to build the next whatever-feature, and during that process, you realize some other bug that needs fixed, but isn’t necessarily a part of your whatever-feature? Here’s an alternative to handle that situation:
1 2 3 4 | $ git stash [fix the bug] $ git commit -a -m "bug is now fixed" $ git stash pop |
git stash saves your changes and gives you a clean tree. Then you can do whatever it was you wanted to do (in this case, fix the bug) and commit it. git stash pop brings your changes back, and you can continue as if nothing ever happened. Sweet.

Chris Scharf Friday, 17 Apr, 2009 Posted at 10:36AM
git stashis very useful when working withgit-svn– sometimes I need to rebase before I push to svn, so I usuallygit stash,git svn rebase, and thengit stash apply. Also note that you can name your stashes:git stash save fixing_user_model.Ben Thursday, 28 Jan, 2010 Posted at 07:54PM
@Chris:
If you develop in a separate branch to master, you shouldn’t need to stash your changes before you rebase.
1.
git branch -b in-progressMoves to a new branch2.
[WORK WORK WORK]3.
git checkout mastertakes you back to the version before your changes4.
git svn rebasepulls down new changes from svn5.
git merge in-progressapplies your changes back to master6.
git svn dcommitcommits master