Branches and remotes
Autostash on pull, Sync and checkout
2 min read
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.
- Preferences (Ctrl+,) › Operations › Pull, checkout and push › Autostash.
- On a refused checkout (with checkout autostash off), the error notice offers Check out with autostash.
| Option | What it does | Default |
|---|---|---|
| On pull (and Sync) | Adds --autostash to the pull from the button, the arrow and Sync. | off |
| On checkout | Puts the changes away before any checkout (branch, remote branch, tag, commit) and gives them back afterwards. | off |
- With changes in
src/app.ts, double-clickdevelop. - Git refuses because
src/app.tswould be overwritten. The notice says: "You can check out with autostash: the changes go to a stash and come back after the switch." - Click Check out with autostash.
- The changes go into a stash, the checkout happens and the changes come back on
develop.
On pull and Sync, git itself takes care of the stash:
git pull --rebase --autostash # the default mode, plus --autostash
On checkout, Versora puts the changes away and gives them back:
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).
- 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.
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).
- "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.