I just committed the wrong source to my project using --force option.
Is it possible to revert? I understand that all previous branches have been overwritten using -f option, so I may have screwed up my previous revisions.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Git generally doesn’t throw anything away, but recovering from this may still be tricky.
If you have the correct source then you could just push it into the remote with the
--forceoption. Git won’t have deleted any branches unless you told it to. If you have actually lost commits then take a look at this useful guide to recovering commits. If you know the SHA-1 of the commits you want then you’re probably OK.Best thing to do: Back everything up and see what is still in your local repository. Do the same on the remote if possible. Use
git fsckto see if you can recover things, and above all DO NOT rungit gc.Above above all, never use the
--forceoption unless you really, really mean it.