Managing Context Switches in TortoiseGit with Stash
Stop cluttering your Git history with 'WIP' commits. Learn how to use TortoiseGit's Stash feature to safely park uncommitted changes and switch branches instantly.
23 Sept 2025, 16:55 UTC

The "Half-Finished Feature" Dilemma
You are deep into a complex feature implementation with several files modified, but you aren't ready to commit because the code doesn't compile or the logic is incomplete. Suddenly, a critical bug report arrives that requires an immediate fix on the main branch. You cannot switch branches because Git will block the checkout to prevent overwriting your uncommitted changes.
The common instinct is to create a "temporary" commit with a message like "WIP" or "temp save." However, this litters your commit history with noise that must be cleaned up later via interactive rebasing. The efficient solution is Stashing—a way to push your current dirty working directory onto a local stack, cleaning your workspace instantly without creating a permanent commit.
How TortoiseGit Handles the Stash Stack
In the command line, git stash is a simple stack (Last-In, First-Out). TortoiseGit transforms this into a manageable visual list. When you use the Stash Changes command, the tool doesn't just save the state; it allows you to assign a descriptive name to that specific snapshot. This is a significant quality-of-life improvement over the default Git index, where you are often left guessing which stash@{2} contains the CSS fix versus the API refactor.
TortoiseGit allows for Partial Stashing. Instead of saving every single change in the repository, you can select specific files in the stash dialog. This is useful when you want to move some changes to a different branch while keeping others in your current working tree for immediate testing.
Practical Workflow: Stashing and Popping
To move from a feature branch to a hotfix and back, follow this sequence using the Windows Explorer context menu:
- Save State: Right-click your project folder →
TortoiseGit→Stash Changes. In the dialog, enter a message (e.g., "Feature X - halfway through auth logic") and click OK. Your working directory is now clean. - Switch Context: Right-click →
TortoiseGit→Switch/Checkout. Select themainorhotfixbranch. - Perform Fix: Commit your bug fix and push it to the remote.
- Restore State: Switch back to your feature branch. Right-click →
TortoiseGit→Stash Pop.
Stash Apply vs. Stash Pop
When restoring your work, you will encounter two primary options. Choosing the right one depends on whether you want to keep a backup of the stash:
| Action | Effect on Working Directory | Effect on Stash List |
|---|---|---|
| Apply | Integrates changes into current files. | Stash entry remains in the list. |
| Pop | Integrates changes into current files. | Stash entry is deleted upon success. |
Critical Limitations and Risks
Stashing is a powerful local tool, but it has two primary risks that can lead to data loss or frustration:
- Local Scope: Stashes are stored in the
.gitdirectory of your local machine. They are not pushed to the server. If your local drive fails or you delete the local repository, your stashed changes are gone permanently. - Merge Conflicts: If you modify the same lines of code on your branch while your changes are stashed, performing a
Stash Popwill trigger a merge conflict. You will have to resolve these manually using the TortoiseGit Merge tool before the stash can be successfully cleared from the list.
Verification and Recovery
To verify your current stashes without applying them, right-click → TortoiseGit → Stash Pop. This opens the stash list dialog, showing all saved states and their timestamps. If a pop fails due to a conflict, the stash is not deleted; it remains in the list, allowing you to abort the operation or try applying it to a different branch.
For those who prefer the CLI for verification, run git stash list from the repository root to see the raw index of saved states.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.