Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are Git Stashes stored?

Tags:

I have been using PhpStorm and recently stashed a load of my changes. At some point after that, my PC profile became corrupt and had to be rebuilt.

Now that I have a new PC profile, PhpStorm is not showing my stashed changes.

Is there any way I can get them back?

like image 856
Typhoon101 Avatar asked Nov 17 '16 11:11

Typhoon101


People also ask

Where are stashes stored git?

All are stored in . git/refs/stash . git stash saves stashes indefinitely, and all of them are listed by git stash list . Please note that dropping or clearing the stash will remove it from the stash list, but you might still have unpruned nodes with the right data lying around.

Are git stashes saved locally?

Note that the stash is local to your Git repository; stashes are not transferred to the server when you push.

How do I access my git stash?

To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.

Is git stash stored remote?

Git stash saves the uncommitted changes locally, allowing you to make changes, switch branches, and perform other Git operations. You can then reapply the stashed changes when you need them. A stash is locally scoped and is not pushed to the remote by git push .


1 Answers

From the docs, the latest one is stored in ./.git/refs/stash while older ones are in the reflog of that ref.

As an aside, I've found it's a bad practice to maintain a regular use of git stash. Generally, prefer many small commits on a feature branch. This way you rarely have to stash and when you do it's very little stored as such. I generally stash only when I need to touch something away for a few minutes, and then apply when I'm done looking at something.

https://git-scm.com/docs/git-stash

like image 50
Paul Avatar answered Oct 06 '22 22:10

Paul