Child pages
  • Getting Started with Git

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: checking out of stash. very cool!


Code Block
git reset --hard

Stash to Clean and Checkout from Stash to Work

Say that you have several different things going on in your project at any one time. How can you seperate them to check something in? You know about the "git stash" command, which cleans up your project. But what if you want part of the dirtiness, but not all of it?

Suppose you have,,, and You have a single feature implemented in and and those edits stand on their own. If you are going to check in just and, you should test them on their own, without your other changes. First, do a "git stash". A "git status" will show you have no staged changes. Now do:

Code Block

git checkout stash@{0} --
git checkout stash@{0} --

Now you have your two files and not the others and you can build and test them in a clear project before you check them in!
One odd thing I noticed is this. The "git diff" you were doing before the stash will show your changes. Now you have to do "git diff HEAD". Not completely sure why, but there it is.