Using the Stash
The Stash is a kind of "clipboard" for your local changes: it saves all of your uncommitted changes and leaves your working copy in a clean state. You can restore it later, at any time.
When to Use the Stash
In your daily work, you'll often need to quickly get a clean working copy. This is advisable (or even necessary) before switching branches, performing a pull, merge, rebase, or cherry-pick. Instead of committing half-done work, you can use the Stash to safely store your local changes temporarily.
You can create as many Stashes as you like and restore them whenever and wherever you like (independent of the current branch).
Saving Changes on a Stash
Since stashing is such an important feature, Tower makes using it very easy: in the toolbar, you can click ⌘ + ⇧ + S at any time to save your current local changes.or press
Providing a short but descriptive message will help you distinguish different Stashes later. As an option, Tower also offers to include untracked files when saving a Stash.
Please be Careful!
Stashing untracked files in Git can remove ignored files & folders as an undesired side-effect! This depends on how exactly the ignore rule is shaped: e.g. a folder that was ignored with /ignored-folder/* will be removed after stashing untracked files. In contrast, if the ignore rule is /ignored-folder, Git will not purge it.
Please note that this (definitely debatable) behavior is part of Git, not Tower. Read more about this issue here.
Saving Individual Files on a Stash
Occasionally you might need to save individual files rather than the whole set of changes in your working copy. Tower offers a quick way to partially stash files: simply right-click on them and select "Stash filename" from the context menu.
Holding down the ⌥ key will perform this action in a quick variant, without a dialog.
Inspecting Saved Stashes
To display a list of your saved Stashes, either select the Stash item in Tower's sidebar or press ⌘ + 3. On the right, detailed information like the date, message, and changes for the selected item is shown.
Applying Changes from a Stash
To reapply a Stash - and thereby restore its changes in your working copy - you can perform one of the following actions:
- Use the button in the toolbar
- Right-click an item in the list of Stashes and select
- Use the
button below the header of a Stash item's details view
In the "Apply Stash" dialog, the following options are provided:
- "Delete Stash After Applying Changes" will directly delete the Stash after it was successfully applied.
- "Restore Staging Area Status" will try to also restore the status of the Git index for the stashed changes.
Applying Parts of a Stash
You can also choose to apply only parts of a Stash: simply drag the change you want to apply and drop it onto the Working Copy item in the sidebar.
Automatic Stashing in Tower
In a lot of situations, having a clean working copy is (almost or indeed) mandatory - for example when checking out a different branch or when pulling from a remote. Since it's all too easy to forget to stash before starting such an operation, Tower's "Auto Stash" feature comes in handy: if you have uncommitted local changes, Tower will offer to automatically stash them for you.
If you should not want this, you can switch Auto-Stashing off in Tower's preferences.