Search code examples
gitgithubgitlabpullgit-reset

Gitlab: The resource you were looking for doesn't exist - How to undo a pull


I've researched some of git undo methods, but they don't really solve my specific problems. So I hope someone can help with this. Thank you in advance!

We are using GitLab to submit our CS homework. Basically, I have a GitLab online repo (remote origin master), and a local repo. This is how the homework process goes:

1.I have two remote, my own GitLab repo, my professor's GitHub repo.

2.The professor updates homework in his GitHub repo.

3.I pull the new homework to my local repo.

4.After I finish my homework, I add-commit-push it to my origin master (my GitLab repo) for the professor to review.

5.The professor puts his comments into my GitLab repo.

6.I pull the commented homework from GitLab repo to my local repo.

This time, something went wrong. GitLab shows that my professor pushed something to my GitLab repo, however when I view the file online, I couldn't open my repo and got this message:

404 The resource you were looking for doesn't exist.

After seeing this, I did something really silly. I went ahead and did a git pull, thinking that the problem was just the internet. This is what I did:

git pull origin master

Turns out it's not the internet, it's my repo. When I opened my local repo file, all my code assignments are gone. My local repo was empty. Only a few folders were left with nothing in them.

So the problem in short is: codes in my local repo are gone; my online repo can't be opened and I suspect it's also empty.

I tried

git reset head 

and

git reset head~ 

but nothing happened.

I'm not sure what's going on and am really worried because another homework set has just begun, and my repo is still messed up. Could anyone please help me out with this issue?

Thanks a million.


Solution

  • Try at least a git reflog: you should see your commit (before the pull) in there, which means you can reset to that commit, and find back your work.

    Then try a git fetch, and as advised in the comments, a

    git log --oneline --abbrev-commit --branches=* --graph --decorate --color
    

    That will give you a better vision of how origin/master is compared to your local master branch.