Eray
Eray

Reputation: 7128

Some Files Disappeared After Git Stash

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 ?

Upvotes: 9

Views: 5515

Answers (3)

Adem Tepe
Adem Tepe

Reputation: 768

It has been 5 years since the question was asked but maybe this answer will be beneficial for contemporary members.

I am writing this answer for those who have faced the same issue and use (or would use) NetBeans IDE.

SOLUTION: In NetBeans, click on your project name, then from the main menu choose Team => History => Revert Deleted. Wait a little and NetBeans will list previously deleted files. Select the ones you need and click OK.

That's it, no need to struggle with any command, thanks to NetBeans for this practical solution!

Upvotes: 0

Eray
Eray

Reputation: 7128

I found answer in same time with @kostix .

git reset --hard 46dbc13

solved my all problem. I found this command from here : https://stackoverflow.com/a/4114122/556169

Upvotes: 1

rynmrtn
rynmrtn

Reputation: 3419

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}

Upvotes: 7

Related Questions