Recover ignored directory from dropped stamp in Git

I lost the ignored (specified in .gitignore) directory by running unnecessary files and then breaking through the pop.

I had a lot of changes, all concentrated in one commit (large sections of code moved to new files, reordered code, single-line changes, etc.). I wanted to split them into several separate commits. First, I created a new branch and checked it to be safe. I reset to the previous commit and used git add --patch to go through all the changes and selectively index the ones I wanted to include in the first new commit. I also wanted to include a couple of new files that I created, so I had to add them too. Once my index reflected the changes I wanted for the first new commit, I used git stash save --keep-index --include-untracked to hide the raw changes and leave only the indexed changes in the working directory so that I could test them before committing. Once I was happy with the commit, I would do this, pull the changes from the wallet and start selectively adding changes for the next new commit.

Now I screwed up several times. Firstly, I forgot --include-untracked in stash, so there were still all the new files in my working directory that I did not want. I immediately realized and tried git stash pop to try again, but I had merge conflicts. I was not sure how to merge correctly, with all the selectively added changes, so I returned to the owner, created a new branch and checked it, hoping that everything I had done in the first new branch would remain there (as far as I was wrong .. .).

The next time (after selective addition again, phew ..), I forgot to add new files that I wanted to include in the commit, so they were hidden. I switched back to the wizard, made a new branch and tried again.

I had to do this at least 3 or 4 times before being "right." But when I went to check my code, it could not find one of the input files that I used. The file was in my "ignore" directory, which was specified in .gitignore. When I looked, the whole directory was missing. I used a lot of files - database files, etc. β€œI wanted to keep them, but not track their changes.”

So, I looked at the git stash list . It indicated about 5 vices, 4 of which I just created, as described above. I realized that they did not stay beautifully in their branches. Then I tried to find the "ignore" directory in stashes. I tried to pop out each one of them, but continued to encounter merge conflicts, and I was never sure how to resolve them - when I thought that I still existed on the list, but seemed to be partially applied. I ended up trying to pop, and then dropped every cache in the list, always watching how my lost directory appeared. This is not true.

I followed the instructions on how to recover a fallen file in Git? to look at my history in gitk, but could not find my missing directory; none of the commits listed have it in the "Tree" or "Patch" view, which may make sense because it should ignore it. I looked, in particular, at those that denoted WIP, but did not play dice.

I also tried to check every branch I made, but to no avail.

How do I track it? It is not in a (non-stash) commit anywhere because it has never been tracked. I suppose he retired with his wallet, but maybe I'm wrong. How to find my abandoned stamps and choose the right option - can I search by content? When I find it, how to make it apply without conflict?

Attempted Updates

 $ git reflog --all 25b96f2 refs/heads/ recover0@ {0}: commit: trash fbf987b refs/heads/ recover0@ {1}: commit: trash de24fd2 refs/heads/ tmp2@ {0}: branch: Created from de24fd 78f64c9 refs/heads/ fix0dot1@ {0}: commit: temp commit d 6aaa987 refs/heads/ tmp0@ {0}: branch: Created from 6aaa987 6cab748 refs/heads/ exp6@ {0}: commit: trash 7cab1c1 refs/heads/ tmp4@ {0}: branch: Created from 7cab1c bc60313 refs/heads/ tmpA0@ {0}: branch: Created from bc6031 38389f3 refs/heads/ a1a@ {0}: branch: Created from master f01ca25 refs/heads/ tmp5@ {0}: branch: Created from f01ca2 0d59a2d refs/heads/ tmp6@ {0}: branch: Created from 0d59a2 43a9dc8 refs/heads/ tmp7@ {0}: branch: Created from 43a9dc e8dd137 refs/heads/ exp5@ {0}: branch: Created from master 207bfea refs/heads/ exp3@ {0}: commit (amend): temp commit c 996a20b refs/heads/ exp3@ {1}: commit (amend): temp commit c a1713f8 refs/heads/ exp@ {0}: rebase -i (finish): refs/heads/exp onto 7d5e666 09d03de refs/heads/ exp@ {1}: branch: Created from master 7d5e666 refs/heads/ exp4@ {0}: reset: moving to HEAD^ 149c949 refs/heads/ exp4@ {1}: commit (amend): temp commit a b4d9cbc refs/heads/ exp4@ {2}: rebase -i (finish): refs/heads/exp4 onto 75f8808 e8dd137 refs/heads/ exp4@ {3}: branch: Created from master ec8afef refs/heads/ exp6@ {1}: reset: moving to HEAD^ 7d5e666 refs/heads/ exp6@ {2}: reset: moving to HEAD^ 38389f3 refs/heads/ exp6@ {3}: branch: Created from master 7e66c30 refs/ stash@ {0}: WIP on master: 662f5b9 fix #6: Print time used f2e045e refs/heads/ tmp8@ {0}: branch: Created from f2e045 b780d56 refs/heads/ tmp3@ {0}: branch: Created from b780d5 
+1
source share
1 answer

git reflog --all should include dropped stamps. You can see his name (it's something like stash@ {N} ), and then use git show or reset or what to see.

If you cannot find it from reflog, I don't think you can repair it with git.

There is a reason why unrecovered files are called. I would recommend that you make sure that you produce any files / directories that interest you. Thus, you can restore them normally.

+2
source

All Articles