Git stash Stashing Function: Temporarily Save Uncommitted Code

Git stash is used to temporarily stash uncommitted changes in the working directory and staging area, avoiding conflicts when switching branches or pulling code. It saves the modifications and restores the working directory to the state of the most recent commit, without retaining branch information. Core commands: `git stash` to stash changes, `git stash apply` to restore the most recent stash (without deletion), `git stash pop` to restore and delete (recommended), and `git stash list` to view stashes. A practical scenario is urgent bug fixing: stash changes → switch branches to fix → restore stash. Note: Stash is temporary, and conflicts may occur during restoration. The difference between `pop` and `apply` is whether the stash record is deleted. Stash is not a branch. Master the core commands, clean up stashes after use, and keep the working directory tidy.

Read More