Deleted gh-pages branch

Viewed 120

I am having a problem where https://lindsayreiner.github.io (https://github.com/lindsayreiner/lindsayreiner.github.io) deployed portfolio page is not updating after pushing changes from my local branch.

I found this Stack Overflow discussion which describes my problem exactly but in an attempt to fix the issue I followed the advise in the 2nd answer by doing:

git push origin :gh-pages
git push origin gh-pages

which gave me an error that the gh-pages branch does not exist.

So now my deployment isn’t reflecting the code base in the repository and I don’t have a gh-pages branch.

How do I restore my gh-pages branch and get my deployment to be in line with the code in my repo?

I’ve tried updating my index.html file in the GitHub website prior to deleting the gh-pages branch and this did nothing, and I also cleared my cache and did a hard reload and that didn’t do anything either.

1 Answers

You should be able to query the recent push events from your GitHub repository:

curl -u "username:PersonalAccessToken" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/RepoOwner/Repo/events

Replace RepoOwner and Repo with your GitHub account and repository name.

Look for a DeleteEvent with its matching SHA1, and try and fetch that (git fetch SHA1, replace SHA1 with the actual SHA value).

Then:

git switch -c gh_pages SHA1
git push -u origin gh_pages
Related