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'
.
Asked
Active
Viewed 79 times
0

The Wizard
- 943
- 7
- 21
-
Is it possible to restore to this: https://github.com/MixtapeDistrict/server/tree/890dbfa4a5479cf849f2e2b525b9609a26e19573 – The Wizard May 08 '15 at 05:43
-
From this: https://github.com/MixtapeDistrict/server – The Wizard May 08 '15 at 05:44
1 Answers
2
You did force push which will overwrite whole commit history in the branch.
You have made two mistakes:
- It looks like you did not clone the respository but copied and called git init.
- You can make a separate branch and merge with the master, but you did not.
You can try the following:
- 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.
- 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:

Community
- 1
- 1

doptimusprime
- 9,115
- 6
- 52
- 90
-
Well, I can access the repository right here will the commits inside: https://github.com/MixtapeDistrict/server/tree/890dbfa4a5479cf849f2e2b525b9609a26e19573 – The Wizard May 08 '15 at 05:21
-
-
-
See the edit and this link: http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html – doptimusprime May 08 '15 at 07:51
-
Thanks, I ended up using another member's local copy (which had all the commits) and doing git push origin master -f on that. – The Wizard May 08 '15 at 11:25
-
Additionally, GitHub responded to their email today and they were really helpful. They created a new branch for me which I could optionally revert to if I liked. =) – The Wizard May 10 '15 at 07:34