LOADING

Enable the browser cache if loading is slow

Why we need git stash

2023/7/12 tech tech git

Git stash is used to temporarily save changes that are not ready to be committed or pushed to a branch.

And use git stash pop or git stash apply to restore it.

It was designed to help modify other files temporarily.

That’s a creative feature.

But……

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.

Wow, amazing.

img

A file 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.