I have a bunch of note as html files and want to easily host them somewhere. I’m looking into using GitHub Pages. GitHub pages provide themes, but for html files you need to add a header to the start of each file in markup format using Jekyll Front Matter.
Add a sample test page with a couple of headers and you end up with a page rendered with your selected theme:
Access your site with the url: https://[your-github-user-id].github.io/[repo-name]
Personal Access Token’s are used to grant access to one of your repos with specific permissions. They have an expiry, so when one expires you need to recreate a new one, details are here.
If you’re trying to push and your token has expired, you’ll see an error like this:
> git push
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/youraccount/yourrepo
The first time accessing a repo requiring authentication is simpler because it will prompt you for your id and password (or token). Once you’ve set one up though, it’s not as obvious how to reset a new token value, since the git cli only gives you the above error, it doesn’t prompt you to enter a new password/token.
To replace your cached credentials, use these steps (from here):
If you’ve committed a number of git commits using a wrong user.name or user.email value, you can re-write previous commits with:
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "Old Name" ];
git commit-tree "$@";
git commit-tree "$@";
Note that this will re-write all commits on the current branch matching the if condition which may or may not be what you’re looking for, so be careful. push the changes back to your remote origin as needed.
By default, the git install on my MacOS 11.5 creates new projects with a ‘master’ branch, but GitHub which I push to for my remote projects has been creating new projects with a default branch of ‘main’ for some time now.
To move a master branch to main locally, set it as the default branch and then push to GitHub I use the following steps (taken from multiple places but mainly from this article):
Create a new main branch from master locally:
git branch -m master main
Add remote GitHub repo:
git remote add github https://your-repo-url
Pull remote changes from remote main branch
git pull github main
Set upstream branch to track main
git branch --set-upstream-to github/main
Push local to github main
git push github main
If you have changes in the new remote project (like a readme) that don’t exist locally yet and you get the error: “fatal: refusing to merge unrelated histories” then pull with the allow unrelated histories option: