Skip to content
Versora

Manual

Branches and remotes

Autostash on pull, Sync and checkout

2 min read

On this page

Pull and checkout refuse when you have uncommitted changes that would be overwritten. Autostash solves that on its own: it puts the changes in a stash before the operation and gives them back at the end. If they don't come back cleanly, the stash is kept and Versora tells you.

Where to find it

  • Preferences (Ctrl+,) › Operations › Pull, checkout and push › Autostash.
  • On a refused checkout (with checkout autostash off), the error notice offers Check out with autostash.
OptionWhat it doesDefault
On pull (and Sync)Adds --autostash to the pull from the button, the arrow and Sync.off
On checkoutPuts the changes away before any checkout (branch, remote branch, tag, commit) and gives them back afterwards.off

Step by step: a one-off checkout with autostash

  1. With changes in src/app.ts, double-click develop.
  2. Git refuses because src/app.ts would be overwritten. The notice says: "You can check out with autostash: the changes go to a stash and come back after the switch."
  3. Click Check out with autostash.
  4. The changes go into a stash, the checkout happens and the changes come back on develop.

What Versora does in git

On pull and Sync, git itself takes care of the stash:

bash
git pull --rebase --autostash          # the default mode, plus --autostash

On checkout, Versora puts the changes away and gives them back:

bash
git stash push -q -m "Versora autostash before checking out develop"
git checkout develop --
git stash pop --index -q               # if that fails, it tries: git stash pop -q

--index also tries to give back what was staged. Only tracked files go into the autostash: new (untracked) files stay where they are, as with git's own autostash.

Without the option on in Versora, the pull uses whatever is configured in your git (rebase.autoStash, merge.autoStash).

When the changes come back with a conflict

  • With a conflict: "Your local changes came back with conflicts: resolve the conflicted files. A copy of them is still in stash@{0}; drop it once you're done." Resolve the files in the "Conflicted" section and then delete the stash.
  • When they can't be reapplied: "Your local changes couldn't be reapplied and are still in stash@{0}." The changes are safe in the stash; apply it whenever you want.
  • If the operation itself fails after the stash: "Your changes were kept in stash stash@{0}: apply it whenever you want."

In the first two cases the notice has Show the stash, which selects the stash in the graph.

How to undo

Ctrl+Z undoes the pull or the checkout as usual. The autostash's stash, if it was kept, shows up in the STASHES section and can be applied or deleted from its menu (see Undo: stash).

Caveats and messages

  • "The automatic stash (…) is no longer in the list: check your stashes.": the stash was touched outside the app during the operation. Check the STASHES section.
  • Stack operations (update, sync, move) also put away and give back the changes on their own (see Stacks).
  • Preferences › Operations › Pull, checkout and push › Autostash.

See also