Tower Icon

Using the Stash

Git's "Stash" allows you to save your current changes without making a commit. Think of the Stash as a kind of "Clipboard": It saves all the modifications from your tracked files and leaves your working copy in a clean state.

Imagine the following scenario for an example of when to use the Stash:
You're working on a feature and have a couple of files modified. Then, an urgent bug report comes in that you need to address immediately. To be able to start working on the bugfix you should have a clean working copy. But you don't want to make a commit with the half-done work from your feature. That's when the Stash comes in handy: it saves all your work so that you can continue later and leaves you with a clean working copy.

NOTE:Stashing only takes files into account that are already tracked. Untracked files (marked with a '?' icon in the file list) are left untouched by the Stash.

To save your changes to the Stash

  1. If untracked files (marked with a '?' icon in the file list) are amongst the files you want to save to the Stash you can simply stage them to have them included.

  2. Click the "Save Stash" toolbar button. In the following dialog you can (but don't have to) enter a description for this Stash. If you enter a description it will be shown in the Sidebar.

  3. You will be left with a clean working copy and a new Stash item in the Sidebar.

NOTE:You can save multiple changesets as individual Stash items - and reapply or delete them as you like. If you don't enter a description the newest item will always be named "stash@{0}" and is listed at the top.

To reapply changes from the Stash

All available Stashes for this repository are listed in the Sidebar under the "Stashes" section.

  1. Select the stash item you want to reapply and either right-click and select "Apply Stash..." or drag and drop the item onto your current HEAD branch item in the Sidebar.
    TIP:If you mouse-over the Stash item in the Sidebar the appearing tooltip shows you the description text (if one exists for this item).

  2. After confirming the following dialog the saved changes will be reapllied on your current working directory.

To display the list of changed files and show the Stash Diff

  1. Select the stash item in the sidebar.
    TIP:If you mouse-over the Stash item in the Sidebar the appearing tooltip shows you the description text (if one exists for this item).

  2. Select the Commits view. The latest commit in the history is the stash commit. It contains the diffs of only the stashed files.


Related Topics

Overview of the Status area

Staging Changes

Committing Changes