The Wizard
The Wizard

Reputation: 953

GitHub commits got deleted


I was working on my local copy of a GitHub project. After changing a few files, I tried to commit and I got the message This is not a github repository, so I did git init, git add . and committed (After adding the remote origin), and did git push origin master -f.
Now all the commits are gone except my one. Is there anyway to restore these commits as they are really important? I tried git reset 890dbfa4a5479cf849f2e2b525b9609a26e19573, but I get the message Could not parse object '890dbfa4a5479cf849f2e2b525b9609a26e19573'.

Upvotes: 0

Views: 103

Answers (1)

doptimusprime
doptimusprime

Reputation: 9405

You did force push which will overwrite whole commit history in the branch.

You have made two mistakes:

  1. It looks like you did not clone the respository but copied and called git init.
  2. You can make a separate branch and merge with the master, but you did not.

You can try the following:

  1. Try to clone the repository from github and see if it contains these objects which you are trying to reset. If yes, then it is okay.
  2. else, contact github support for full recovery of your folder. If unused objects are not cleaned, then that might help you. Original folder might have previous objects.

You can refer the following link for further help:

  1. Undoing a 'git push'
  2. How to recover from a git push -force?

Upvotes: 2

Related Questions