In the course of our work, we come across such problems from time to time. A bug occurred while the current branch was working on functionality, requiring switching to another branch. But the changes to the current branch are not ready to commit. So we can cache the current workspace using the following method:

You can use Git Stash before switching branches

Switch the branch to the git checkout master

When you’re done, go back to the development branch and execute

Git stash list git stash list git stash list

There are two ways to recover

Method one:

$git stash apply $git stash apply $git stash drop $git stash apply $git stash drop

Method 2:

Git stash pop stash@{0} git stash pop stash@{0}