Git stash is used to temporarily save changes that are not ready to be committed or pushed to a branch.
git stash pop or
git stash apply to restore it.
It was designed to help modify other files temporarily.
That’s a creative feature.
Why don’t use
git checkout -b [newbranch] to create and check out to a new branch to do my work?
To untangle the paradox, we need try it first.
git init vim test1.txt git add . git commit -m "commit" git checkout -b dev vim test2.txt git checkout master ls
Run this command in a blank dictionary, you can find test2.txt.
test2.txt belonging to the dev branch appeared in the master branch.
So, that’s why we need git stash.
Any file change will appear in all branches.