Eugene Yarmash
Eugene Yarmash

Reputation: 149736

How do I apply autostash after an aborted rebase?

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:

Upvotes: 4

Views: 1214

Answers (2)

Eugene Yarmash
Eugene Yarmash

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

user3159253
user3159253

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

Related Questions