Jérôme Pouiller
Jérôme Pouiller

Reputation: 10197

Where is the temporary stash entry created by `git rebase --autostash`?

I am used to run git rebase --autostash. For several reasons (conflict, edition, etc...) I may be interrupted during the rebase. I expect to see the autostashed content in the output of git stash list. But it is not. Where the temporary stash entry is located? How to see it?

Upvotes: 1

Views: 151

Answers (1)

LeGEC
LeGEC

Reputation: 51790

While the rebase is going, the autostash is stored in : .git/rebase-merge/autostash.

Since this file is stored under .git/, and is a valid reference file, you can use rebase-merge/autostash as a name to point to the autostash :

git log --oneline --graph rebase-merge/autostash

# you can also use it with 'git stash show' or 'git stash apply' :
git stash show rebase-merge/autostash
git stash apply rebase-merge/autostash

You can also "insert" it in the regular stash by manually calling git update-ref refs/stash :

git update-ref -m "autostash" refs/stash rebase-merge/autostash

note : before reading your question I also thought the autostash was as a regular stash, I just found out about the tricks above by inspecting the content of .git/rebase-merge/.

The hacks above work at the moment (git version 2.31), I don't think you should count them as a rock solid, forever stable feature -- for example the internal structure of the .git/rebase-merge/ directory isn't part of the documentation.


and obviously, if you run git rebase from a terminal, you can also see the hash of the autostash in the command's output :

$ git rebase -i master 
Created autostash: 2acfb51
...

Upvotes: 3

Related Questions