Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some Files Disappeared After Git Stash

Tags:

git

I'm working on directory. I've made some modifications since my last commit. And i want to ignore all this modifications (which after my last commit) . In shortly, i want to turn back my last commit . I've accidentally execute wrong command and i have execute this:

git stash
Saved working directory and index state WIP on master: 46dbc13 Ayarlar activity geri butonu
HEAD is now at 46dbc13 Ayarlar activity geri butonu

After this, most of my files (my all image files) gone away. But they were exist in my last commit (#46dbc13). They are deleted after my stash. I have no idea. I have executed git stash apply but nothing changed.

Can you tell me what's happening ?

like image 933
Eray Avatar asked Jun 18 '13 12:06

Eray


People also ask

How do I get my files back from git stash?

Retrieve Stashed Changes 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.

Where do git stash files go?

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.

What happens after git stash?

git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.

Does git stash remove new files?

But git stash by itself stashes only the changes to the existing file; the new file remains in my working tree, cluttering up my future work. How do I stash this untracked file? – Maxime R.


1 Answers

git stash is a mechanism to "put your changes aside". I see it used most frequently when you're in the middle of writing new functionality but have to switch to something of a higher priority.

If you'd like to see a list of your stashes, you can go with git stash list and see something similar to the following:

git stash list
stash@{0}: WIP on master: 46dbc13 Ayarlar activity geri butonu

If you would like to apply your changes, you're going to have to either go with one of the two following commands:

Pop: this will pop the top stash off your stack

git stash pop

'Apply': this will apply a given stash. If your git stash list has just the single stash (like is given above), you can use this. If you have multiple stashes, you will need to apply the specific stash you wish to apply.

git stash apply stash@{0}
like image 51
rynmrtn Avatar answered Oct 09 '22 14:10

rynmrtn