Lost local files in directory while using Git push/pull

43 Views Asked by At

I'm running into the issue that my Github is not collaborating as I want. Yesterday, I tried to push my changes to a remote repository I created. However, I couldn't pull the repository because it couldn't find it so I just uploaded the script using the upload button on Github itself.

Today I tried using a different PC, via VSCode. I initialized a git repository via VSCode in a local directory that contained files that were not in the remote directory. I think I cloned the remote repository onto this PC and now it did work (after authorization) and I thought I could just do the following:

git add
git commit -m
git push

... but I got a merge conflict.

I don't know what exactly happened but somehow I fixed merging issue, but found out that all the original files of the directory were overwritten by the files in the remote repository.

This basically means all the files in the repository are gone, and I can't find them anywhere. When I use git fsck --lost-found I found a dangling tree and used git cat-file -p to restore it, but that didn't lead to any results.

When I use git log, I only see one commit, but I don't know whether that's correct.

When I use git reflog I see

e2b07b9 (HEAD -> main) HEAD@{3}: checkout: moving from main to e2b07b9
e2b07b9 (HEAD -> main) HEAD@{4}: reset: moving to e2b07b9
e2b07b9 (HEAD -> main) HEAD@{5}: reset: moving to e2b0
d487c8d (origin/main) HEAD@{6}: commit (merge): Merge branch 'main' of https://github.com/koenterheegde0507/Pre-Operative-Planning-Algorithm-Koen-TH
e2b07b9 (HEAD -> main) HEAD@{7}: reset: moving to HEAD
e2b07b9 (HEAD -> main) HEAD@{8}: commit (initial): <private data>

I did use git checkout to switch between different HEAD and then used git reset but this also didn't change anything.

So, I have basically no idea what I'm doing but I desperately need those files so if anybody could help, please let me know!

1

There are 1 best solutions below

0
Koen ter Heegde On

I used git stash somewhere in this process and apparently all the files were in this stash. I got them back using git stash apply.