What does git stash do in Git?

What does git stash do in Git?

a) Temporarily saves uncommitted changes
b) Merges branches
c) Deletes a branch
d) Resets the repository

Answer:

a) Temporarily saves uncommitted changes

Explanation:

The git stash command temporarily saves uncommitted changes in your working directory without committing them. It allows you to clean your working directory without losing changes and later restore them when needed.

For example, if you are working on some code but need to switch branches, you can run git stash to save your changes. After switching branches, you can use git stash pop to restore the stashed changes.

git stash is useful for temporarily shelving work when you need to focus on something else or switch branches without committing unfinished changes.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top