How to Recover from rebase and then force push after deleting local repo? #21725
-
I forced pushed to my repo to get a rebase up there. The local repo is no longer around, and the remote repo is now being used. No commits have gone to the github repo since the force push. I’m running into odd errors with portions of code being reproduced twice and it happens in the massive build system too with that being very dificult to track down. Sadly, during the short window my system backup solution was down this happened. I would like to revert the repo to the state the repo was in prior to the force push and rebase, as repairing the errors introduced is taking a long time. I can throw away the repo and patch, but just need my commits and would prefer to know that code at least works with the repo. Anyway to roll the repo back through other methods? I think this is all from me using a rebase based merge strategy, while everyone else just follows the merge commit workflow, or the history of master is getting rewritten some how. If this a history rewritting issue how could I confirm that after the fact? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I don’t know of a way to recover those commits without having the local repository available, specifically Good luck! |
Beta Was this translation helpful? Give feedback.
-
This is certainly a bad situation. You could avoid it however by creating a fork and working against that. It does seem like overkill for private unshared repos but it does avoid this problem. This way you can only ever force push to your fork and must use PR to merge changes from your fork into the original repository. This absolutely eliminates the possibility of commits disappearing. This pattern is good also because you never know when you may invite others to use and fork the repol when all users including you are using the same fork pattern it is a great help. |
Beta Was this translation helpful? Give feedback.
I don’t know of a way to recover those commits without having the local repository available, specifically
git reflog
orgit fsck
. I did some research into how to do a deep clone but that still doesn’t seem to re-enable the typical recovery commands. You may want to contact private support at https://github.com/contact or via email at support@github.com to see if they have any additional options.Good luck!