1

So I originally commit something which included files that weren't meant to be included. I wasn't sure of how to undo it, so I came across this post (How to undo the last commits in Git?) and followed the advice of the second highest answer Kyralessa and typed in:

git reset --hard HEAD~1

What this did was reset my local repository to an older commit (about ~10 commits ago).

So I tried resetting my local copy to the latest commit.

git reset --hard <commit>

Which brings up the following error message:

fatal: ambiguous argument '53430f0': unknown revision or path not in the working tree.

I'm not really sure why as I know that this is the last commit made.

So I then just tried making my local copy match exactly what's in my remote one I meant to write these two commands:

git fetch origin
git reset --hard origin/master

But after I type the first (fetching the origin), it tells me this:

remote: Not Found
fatal: repository <url> not found    

I'm not really sure how it can say this as the repository is definitely there. I mean I'm on it right now.

I imagine it all stems from the initial command I ran but I have no idea what could have went wrong.

EDIT: This was all just a stupid mistake on my part. Apparently I was in of the subdirectories of my repository the whole time (and even for the second time I tried everything).

Hobbit36
  • 255
  • 1
  • 3
  • 11

1 Answers1

0

First, you can retrieve your commit before the reset with git reflog.
You can the use that commit to reset your repo back to its original state.

Second, double-check your remote (git remote -v).
If you know of a remote repo url which has the right state, you can add it with

git remote add origin /url/remote/repo.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250