Stash Your Changes
Sometimes as you make changes in your workspace's repository, you might need to work on another task even when you're midway through some other change. If what you're working on isn't quite ready to be committed, you can temporarily save—or stash—your changes, switch context to do something else, then come back and pick up where you left off.
Create a Stash
You can create a stash when you want to save uncommitted changes in your application. This way, you keep the progress you've made so far without having to commit unfinished, potentially broken, changes.
Stashing saves all the changes you've made in your working branch but not yet committed and reverts the branch's contents to HEAD (the last commit made to the branch). With your changes safely stashed away, you can switch context and freely make other changes. Then when you're ready to resume your work, you can apply the stash and continue where you left off.
To stash uncommitted changes in your working branch:
You can now switch context to perform any Git operation relating to your new task.
To view your stash, click Unstash in the header's Git menu. Stashes are visible across branches, so you can save a stash in one branch, then switch to another branch and apply your stash there.
Apply a Stash
When you are ready to work on something you previously stashed, you can apply that stash to bring back your saved changes and pick up where you left off. You can either apply a stash or pop it to your working branch.
- Applying a stash restores its changes and keeps the stash in the stash list. Do this if you want to apply the same stash to multiple branches.
- Popping a stash restores its changes and removes the stash from the stash list.
To restore changes saved in a stash to your working branch: