As I understand it, Git Stash is a collection of diffs.
So for example, if I have a whole repo with a single file foo.txt
The 32 lines of the file is just
Lorem Ipsum 01
Lorem Ipsum 02
Lorem Ipsum 03
...
Lorem Ipsum 30
a first line: good
a second line: bad
And I committed everything.
Now I create a new branch:
git checkout -b feature123
And now that I am on this branch, I change the word good to better, and bad to worse.
Now, just suppose my program manager comes over and say, "Urgent! We have to change the 01 to 011 and 02 to 022".
So I stash the changes, and then change to the master branch:
git stash
git checkout master
and I changed the 01 to 011, and 02 to 022 as he requested.
And say, I want to incorporate the changes that I "stashed" earlier to the master branch:
git stash apply
but it will error out:
error: Your local changes to the following files would be overwritten by merge:
foo.txt
Please, commit your changes or stash them before you can merge.
Aborting
Why is that? Can't it just apply the collection of diffs to foo.txt?
(P.S. I can commit first, and then use git stash apply, and be able to apply those diffs to foo.txt. But why not before the commit? So git stash really just saves a collection of diffs -- to repeat precisely: a collection of diffs, and then do a git checkout . (to abandon all changes). Is that true?)