Reputation: 149736
I have rebase.autoStash
set to 'true'
in my .gitconfig
, which allows me to run rebase
on a dirty worktree. However, if a rebase
is aborted for some reason, all changes to tracked files are gone (i.e. the autostash is not reapplied). What's the proper way to apply the autostash in such cases?
How to reproduce:
git config rebase.autostash true
.Run git rebase -i HEAD^^^
. This prints something like:
Created autostash: 75a5188
HEAD is now at f0c93f1 WIP
Abort the rebase, e.g. have the editor exit with an error code (:cq
in Vim).
Upvotes: 4
Views: 1214
Reputation: 149736
You can apply the autostash using git stash apply
and the SHA-1 hash that was printed by git rebase
:
$ git rebase -i HEAD^^^
Created autostash: 3ac3f4a
HEAD is now at f0c93f1 WIP
# abort the rebase...
$ git stash apply 3ac3f4a
On branch master
...
Upvotes: 7
Reputation: 17455
Even if git has failed to restore the state, you can always do it manually using git checkout <stash-id> -- .
where <stash-id>
is reported in Created autostash: ...
line
Upvotes: 2