2010-01-12

git stash

I'm currently working on a project using git as my version control system.

Often I'm halfway through making some change or other and an unrelated bug becomes apparent. It's an easy fix and so I go ahead and fix it but then I can't make a clean commit. I found out today how to handle this.

  1. Save the work in progress before the unrelated bug is fixed and run git stash
  2. The source tree is now clean -- the unfinished changes have disappeared. Reload the file in vim and fix the small bug.
  3. Commit the patch
  4. Restore (and merge if necessary) the stashed tree with git stash pop

No comments:

Post a Comment