macOS
Git comes with Apple's command-line tools.
- Do
- In the terminal type
git --version. - If it is missing
- macOS offers to install the developer tools. Press Install and wait a few minutes.
- See
git versionand a number.
Basics · 4
Git keeps the history of every change in your site folder. GitHub keeps a copy of that folder online and builds the site when you send changes. This page sets up both, from a new account to your first push.
About twenty minutes. You can build and look at a site without git, so come back to this page when you want to store the history of your content. Git is the best place to keep a site's content; publishing is a separate choice.
Git is a program that takes snapshots of a folder. Each snapshot, a commit, remembers what changed, when and why. You can look back at any snapshot and undo a change, even weeks later.
GitHub is a website that stores your folder with all its snapshots, called a repository. When you send new snapshots there, a push, GitHub can build a fresh image of your site by itself (GitHub Actions) and store it next to the code (GitHub Container Registry): no extra accounts. With HERON Agent (paid) that image is then also updated on your server. Other ways to publish are on Publish.
An everyday comparison: git is the "track changes" mode of a document that never forgets. GitHub is the shared drive where that document lives, with a robot that prints a fresh copy every time you save.
When you need this page: before publishing with git push or on GitHub Pages. When you can skip it: if you publish by copying files to a hosting yourself.
| Word | Meaning |
|---|---|
| repository | Your site folder together with its whole history. On GitHub it has an address like github.com/you/my-site |
| commit | One saved snapshot with a short note: "New page about prices" |
| push | Sending your new commits to GitHub |
| pull | Getting commits from GitHub to your computer |
| branch | A parallel line of history. Your main one is called main |
| token | A long password for programs, which you can limit and revoke |
| GitHub Actions | GitHub's robot that runs a build after each push |
Git comes with Apple's command-line tools.
git --version.git version and a number.Run HERON and git in the Ubuntu terminal from the Docker page.
sudo apt update && sudo apt install -y gitgit --version prints a version.Usually already installed.
sudo apt install -y gitsudo dnf install -y gitEvery commit carries a name and an email. Set them once on each computer. Use the email of your GitHub account, or GitHub's private no-reply address from Settings → Emails.
git config --global user.name "Anna Smith" && git config --global user.email "anna@example.com" && git config --global init.defaultBranch main
my-site. Leave "Add a README" unticked: your folder already has files.https://github.com/your-name/my-site.git. You need it in the next step.GitHub does not accept your account password from the terminal. You use a token instead: a long password that only works for what you allow and that you can revoke at any time.
Lets your computer send the site to the repository.
my-site..github/workflows/.Needed only if your server downloads a private image of the site from GitHub.
read:packages. Nothing else.docker login ghcr.io, your GitHub name, the token as the password. Details in Publishing with git.A token is a key to your account.
site.yaml, not in a page, not in git.In the terminal go to your site folder and run this, with your user name instead of your-name:
git init && git add . && git commit -m "First version" && git branch -M main && git remote add origin https://github.com/your-name/my-site.git && git push -u origin main
What each part does:
git init turns the folder into a repository;git add . marks every file for the snapshot;git commit -m "First version" takes the snapshot with a note;git branch -M main names the main line main;git remote add origin … remembers where GitHub is;git push -u origin main sends everything.Git asks for a user name and a password: type your GitHub user name and paste the token as the password. Nothing appears while you paste, that is normal. On macOS the keychain remembers it; on Linux and WSL run git config --global credential.helper store once to keep it.
Refresh the repository page on GitHub: your files are there. If the site folder has .github/workflows/, open the Actions tab and watch the first build.
git add . && git commit -m "Prices updated" && git pushIf you prefer buttons, install GitHub Desktop from desktop.github.com (macOS and Windows). Sign in with your GitHub account: no token needed. File → Add local repository → choose the site folder → Publish repository. After that every change appears in the app: write a note, press Commit, then Push origin. VS Code has the same buttons in its Source Control panel.
Yes for private and public repositories. GitHub Actions has free build minutes every month, which is plenty for a site. GitHub Pages on a free account needs a public repository.
Revoke it at once where it was issued (GitHub token page, Docker Hub, the service it belongs to) and create a new one. Deleting the file is not enough: it stays in the history.
A list of files git should not save, like the built dist/ folder and HERON's cache. New HERON sites come with one.
Yes. Git works the same. The automatic build file is written for GitHub Actions; other services need their own. See Publishing.
Publish the site: git push, or for free on GitHub Pages with your domain.