Sobes.tech
Junior — Middle

What is the purpose of the git stash command in version control?

sobes.tech AI

Answer from AI

The git stash command is used to temporarily save changes in the working directory and index that are not yet ready to be committed. This allows switching to another branch or performing other operations without losing current unfinished changes.

For example, if you have started working on a new feature but urgently need to switch to a bug fix in another branch, you can save your current changes to the stash:

git stash

After finishing work on the other branch, you can restore the saved changes:

git stash pop

Thus, git stash helps manage unfinished changes without the need to commit.