JPdL
JPdL

Reputation: 149

restore untracked files after git stash

I created a new repo in github and cloned it inside my already existing project directory in my machine. I migrated specific folders into the cloned project and added a .gitignore to ignore images and track only folders with .py and .ipynb files in it.

When I

git status

I only saw that I can add .gitignore and not the folders that contain the files I want. I pushed it to github and (as expected) saw only .gitignore added in my remote repo.

I thought I cannot add the folders with files I want so I would like to revert to original state (without the gitignore).

Unfortunately, I did

git stash

Now, my original .py and .ipynb files that are not written in .gitignore are gone. How can I retrieve them? I do not have duplicate copies of the project.

Upvotes: 1

Views: 1306

Answers (2)

Amith
Amith

Reputation: 768

If the untracked files were inside the directories you put in .gitignore, then it's probably lost (I encountered this problem when i put directories to be ignored as dir/* format instead of dir/ in the .gitignore file. I believe this bug has been solved in version 2.14.0 (https://github.com/git/git/blob/master/Documentation/RelNotes/2.14.0.txt#L384)

Upvotes: 0

NickDim
NickDim

Reputation: 17

You do a git stash pop to get it back.

Upvotes: 0

Related Questions