Wednesday, 7 November 2012

Git Stash

Sometimes you want to just mess around with some code, maybe write some data buffers to a file to examine or whatever else. This leaves the code in a messy state and whenever you want to switch to a different branch you don't want to commit this code but you also don't want to leave your working directory dirty. For this I am loving Git Stash: Just go to a bash prompt (This is very nice and easy from Git Extensions):

The code must be tracked, if not already then simply:

git add .
git stash save "MyStash"
Coming back to it later:
git stash list
git stash apply stash@{0}
Find your stash with the list command, that will give you the stash number. Then apply Undoing the stash:
git stash show -p | git apply --reverse

No comments:

Post a Comment