Borked my GitHub repo

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I thought I knew what I needed to know about git--apparently I knew just enough to be dangerous. I inadvertently messed up the repo for my Nextcloud script (https://github.com/danb35/freenas-iocage-nextcloud) this morning when I incorrectly set its URL as the remote-url for a different repo. Hillarity did not ensue. The result of that was that six different commits from the wrong repo were merged into this one.

Not a problem, I thought--too bad I can't revert those commits directly through the GitHub web site, but I'll just revert them using a client and then push back to GitHub. Seemed straightforward enough, except that now I'm left with an empty repo. Not truly empty, of course--the history is all there--but there's nothing in the master branch.

The last valid commit was on 9 Dec 20, merging a PR. How do I roll back to that state?
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Multiple solutions here but possibly the simplest is to checkout the last good commit from December b298cdf in your local branch. Then push that to your remote. You will have to force push to make it work so be sure it's exactly what you want. You can always push to a new remote branch of you want to check your work before pushing to master.
 
Top