1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The trick here lies in finding the correct hash ID (SHA-1) of the commit. This is in effect the "true name" of the commit. GitHub never actually delete any commit at all, by default, so even removing all the human-oriented names like `gh-pages` that help Git *find* the hash ID doesn't matter ... *except* that now *you* need to find the hash ID. VonC's method is as good as or better than any other one I know. Ultimately you must find this hash ID; that's what a branch name like `gh-pages` is really about: how to find hash IDs. – torek May 16 '22 at 20:38

1 Answers1

0

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250