I have done something extremely stupid. I tried to fix some merge conflicts in Git, and I don't know what I did, but I deleted my media folder (indirectly), in which I had all the images I needed for my website. I could've pulled from Git, except I can't because .gitignore ignores the media folder. I have no idea what to do.
Here's what I did:
I pulled from git, but it said error: Your local changes to the following files would be overwritten by merge
. So I stashed my directory and then tried to pull again. Because of a few merge conflicts, I stashed, committed, and then tried to reset HEAD to the previous commit (I think this is where the folder got deleted) after git checkout -- .
.
CodePudding user response:
Fortunately : the actions you descibe do not include things that would erase untracked files from disk. Your media folder probably ended up in the stash.
Run git stash list
to inspect how many stashes you have.
You can use regular git commands to inspect the content of a stash. For example, you can list the files in a stash using git ls-tree
:
git ls-tree stash@{xx}
git ls-tree -r --name-only stash@{xx}:media/folder
# actually, 'git ls-tree' works on any commit (not just stashes)
If you see the content you want in one of these stashes, just run :
git stash apply stash@{xx}
# if its the first stash (stash@{0}), shortcut is :
git stash apply