git / git-reference

Online Git Reference at http://git.github.io/git-reference/
Other
996 stars 363 forks source link

Basic ropes on git stash command #53

Closed randomecho closed 11 years ago

randomecho commented 11 years ago

Quick overview on what git stash is and some of the basic commands to run with it.

Going with git stash pop as the default means of extracting from the stack instead of git stash apply. Former feels like the path of least surprise by taking out what you've just put in.

Could fit under the Basic section. Thoughts?

As requested in #36

matthewmccullough commented 11 years ago

From having taught Git in the classroom hundreds of times, I was very surprised that git stash apply turned out to be more helpful in the long run (or at least closely co-taught with pop). Folks were actually surprised in some cases by the removal of the item from the stash with pop. Git would happily blend that with existing modified files (as long as they weren't the same files in the stash), thus making re-creating the same stash a harder experience if the user wanted to git stash save right away again.

git init test1
cd test1
echo JUNK1 > test1.txt
git add .
git stash
echo JUNK2 > test2.txt
git stash pop

This blends stashed and non-stashed stuff together.

Thoughts?

randomecho commented 11 years ago

Could totally swap around apply for pop.

It might still be helpful to leave in the note that if they wanted to shave off the top of the stash list, to go with the latter and beware such ramennoodlefications.

randomecho commented 11 years ago

Got lost on the example though. Only saw a difference in being able to re-apply the stash item using apply whereas pop is no way back. But what it threw back on to the working directory looked functionally the same.

brntbeer commented 11 years ago

I like the idea of keeping git stash drop along side of apply. pop immediately dropping can be a little dangerous and hard for beginners to realize they cant get that stash back.

matthewmccullough commented 11 years ago

I think let's go with this (thank you @randomecho) and iterate on it. This is a super start.