Version control
Stash changes

Stash changes

Stashing lets you save your progress, switch branches to perform another task, then pick up right where you left off. You might use stashing when you need to switch branches in the middle of working on changes, but you aren't ready to make a commit.

Stash and pop changes


Stash and pop changes using the Git interface

Practical example of stashing

Suppose you're working on a feature in a feature branch and you need to switch to the main branch to fix a bug, but you aren't ready to commit your changes.

You can stash your changes, switch branches, fix the bug, then reapply your stashed changes in the feature branch:

Save your changes

Switch to the main branch

Fix the bug

Switch back to your feature branch

Reapply your stashed changes

Terminal

# On 'feature' branch
# Save your changes
git stash save "Work in progress for new feature"