ugit

Overview

Stashes

Stashes are a way to save your uncommitted changes temporarily without committing them. This is useful when you need to switch branches but have uncommitted work, or when you want to set aside changes temporarily.

Stashes


What is a Stash?

A stash takes your uncommitted changes (both staged and unstaged) and saves them as a temporary commit. Your working directory is then cleaned, allowing you to:


Creating a Stash

From Local Changes Panel

  1. Right-click on the Local Changes section in the RepoInfo panel
  2. Select Stash Changes
  3. Enter an optional stash message
  4. Click Save Stash

Stashing Selected Files

You don’t have to stash everything — you can stash only the files you choose.

  1. In the Local Changes panel, select one or more files (or folders) you want to stash
  2. Right-click the selection and choose Stash
  3. Enter an optional stash message
  4. Choose your options (see below) and click Save Stash

Only the selected files are moved into the stash; the rest of your changes stay untouched in Local Changes.

Stash Options

The stash dialog offers two options:

Option Description
Stage new files Includes new (untracked) files in the stash. Git ignores untracked files by default, so leave this enabled if you want them stashed.
Keep changes in working directory Creates the stash but leaves the changes in Local Changes instead of removing them. Useful for snapshotting your work without interrupting it. When disabled (the default), the changes are removed from the working directory after stashing.

Auto-Stash

ugit automatically creates a stash in certain situations:


Viewing Stashes

The Stashes panel shows all saved stashes:

Field Description
Icon Stash indicator (🗂️)
Message Your stash description
Index Stash number (stash@{0} is most recent)

Click on a stash to view its details.


Applying a Stash

Apply (Keep Stash)

Applying a stash brings back the saved changes but keeps the stash in the list.

  1. Right-click on a stash
  2. Select Apply
  3. Resolve any conflicts if necessary

Pop (Apply and Remove)

Popping applies the most recent stash and removes it from the stash list.

This is the same as:

  1. Apply the stash
  2. Delete the stash

Deleting a Stash

Delete a Specific Stash

  1. Right-click on a stash
  2. Select Delete

Clear All Stashes

⚠️ This permanently deletes all stashes.

Stashes can only be deleted one at a time through the UI.


Renaming a Stash

  1. Right-click on a stash
  2. Select Rename
  3. Enter a new message
  4. Click Rename

Saving a Stash as a Patch

Export a stash’s changes to a .patch file you can share or apply elsewhere.

  1. Right-click on a stash
  2. Select Save as Patch…
  3. Choose where to save the file

If the stash also captured untracked files, a second command, Save as Patch (include untracked)…, appears; it adds those files to the patch as new-file diffs. Note that applying such a patch fails if those files already exist in the target working directory.

Patch files can be applied from the repository … menu → Apply Patch…, or with git apply.


Stash Workflows

Workflow 1: Switch Branches with Uncommitted Work

  1. You have uncommitted changes on feature-branch
  2. You need to check main quickly
  3. Right-click → Stash Changes
  4. Switch to main
  5. Do your work
  6. Switch back to feature-branch
  7. Right-click on stash → Apply or Pop

Workflow 2: Pull with Uncommitted Changes

  1. You have uncommitted changes
  2. You click Pull
  3. ugit detects uncommitted work and offers to stash first
  4. Accept the auto-stash
  5. Pull completes
  6. Your stash is automatically applied
  7. Resolve any conflicts if necessary

Workflow 3: Save Work in Progress

  1. You have incomplete changes
  2. You want to try something different
  3. Stash your current work with a message like “WIP: feature X”
  4. Try your experiment
  5. When done, pop the stash to continue

Stash Commands Reference

Git Command Description
git stash Save uncommitted changes
git stash push -m "message" Stash with a message
git stash push -m "message" -- <files> Stash only the selected files
git stash push ... && git stash apply Stash while keeping the changes in the working directory
git stash list List all stashes
git stash pop Apply most recent stash and remove it
git stash apply Apply stash without removing
git stash drop Delete a specific stash
git stash clear Delete all stashes
git stash show -p --no-include-untracked stash@{n} Save a stash as a patch
git stash show -p --include-untracked stash@{n} Save a stash as a patch, including untracked files

Tips

Use Descriptive Messages

When creating a stash, use a clear message:

Don’t Rely on Stashes Long-Term

Stashes are meant for temporary storage. Commit your changes when you’re ready.

Stashes vs Branches


Troubleshooting

Stash Conflicts

When applying a stash, you may get merge conflicts. Resolve them like regular merge conflicts, then continue.

Stash Not Applying

If a stash won’t apply cleanly:

  1. Try git stash drop to remove it
  2. Manually recreate the changes
  3. Or commit your work instead

Lost Stashes

If you accidentally drop a stash, you may be able to recover it with:

git fsck --unreachable | grep commit