Skip to content

Instantly share code, notes, and snippets.

@dannymcc
Created June 13, 2010 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannymcc/436783 to your computer and use it in GitHub Desktop.
Save dannymcc/436783 to your computer and use it in GitHub Desktop.
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:
$ 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.
www.rpheath.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment