I accidentally force push my local file #23816
-
I edit And in my local there were Then I accidentally Are there anyway to recover this? I have tried this but I can’t find the HEAD{x} that contains my |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hey @paraduxos, thanks for being here. Please see here: https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/ for a guide on how to undo almost anything with git. Let me know if you have any follow up questions. |
Beta Was this translation helpful? Give feedback.
-
Hi, I have exactly the same issue but I can’t seem to figure out what section of this guide should help me. I made some changes to my README.md on the 18th. I didn’t pull them down to my local repository. I then made some local changes, committed them, then force pushed to the repository (because I’m an idiot, and couldn’t understand why there was a conflict). Now if I look in the history of my README.md online, it shows only the older commits. There is no record of the changes I made. I know that the forced commit was one of two commits, made on the 18th or the 20th. I tried reverting to one of these commits on my local, but that hasn’t made any difference. I tried cloning the repository and running fsck --full --lost-found, but nothing was found. I can’t see how any of the other suggestions in your link help in this case. Anything I can do, or do I need to re-do my README.md? |
Beta Was this translation helpful? Give feedback.
-
I’m afraid you’ll probably have to re-do the README. Overriding remote-only commits on the pushed branch is exactly what a force push does. I see two other options that might theoretically work, but I have no idea what the chances of them working are:
|
Beta Was this translation helpful? Give feedback.
Hey @paraduxos, thanks for being here. Please see here: https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/ for a guide on how to undo almost anything with git.
Let me know if you have any follow up questions.