Updating
Pull engine fixes and new features into a site you already built, without touching a single note in your vault.
What's yours, what's the template's
| Path | Owner | On update |
|---|---|---|
src/components/, src/layouts/, src/lib/, src/pages/, src/styles/ |
Template | Replaced wholesale |
src/content.config.ts, astro.config.ts, tsconfig.json |
Template | Replaced |
package.json, package-lock.json |
Template | Replaced, then npm install |
content/ |
You | Never touched |
src/config/site.ts |
You | Never overwritten — diff it by hand for new options |
.env, public/favicon.svg, public/og-image.png, README.md |
You | Never touched |
Your vault and your configuration are never named in the commands below. That's why they list the src/ subfolders individually instead of just src/.
Update the engine
Add the template as a second remote. This is once per clone, ever:
git remote add upstream https://github.com/treverehrfurth/astro-publish.git
1. Start clean, on a branch.
git status # commit or stash anything in progress first
git fetch upstream --tags
git switch -c update-engine
2. See what you'd be taking. Your current version is in package.json.
git log --oneline --no-merges v1.4.1..upstream/main
3. Take the engine. The git rm line matters: a pathspec checkout adds and overwrites but never deletes, so without it, files removed upstream would linger in your repo forever.
git rm -r --quiet --ignore-unmatch src/components src/layouts src/lib src/pages src/styles docs
git checkout upstream/main -- \
src/components src/layouts src/lib src/pages src/styles src/content.config.ts \
docs astro.config.ts tsconfig.json package.json package-lock.json .env.schema
Swap upstream/main for a tag — git checkout v1.5.0 -- … — to track stable releases instead of the tip of main.
[!warning] If something goes wrong between those two commands
git reset --hard HEADputs everything back. It restores the deleted folders, drops anything the checkout staged, and leaves untracked files — including draft notes you haven't committed — alone.
4. Pick up new config options. site.ts is never overwritten, so additions won't appear on their own.
git diff HEAD upstream/main -- src/config/site.ts .env.schema
Copy over what you want. Any new environment variables also need adding to your host's build settings — .env isn't read there.
5. Verify, then merge.
npm install && npm run build && npm run preview
git add -A && git commit -m "chore: update engine to v1.5.0"
git switch main && git merge update-engine && git push
package.json now carries the new version, so it stays an accurate record of which release you're running. If you deploy from Cloudflare Pages, the push triggers the deploy on its own.
If you've customized the engine
The steps above overwrite the template's source files silently. If you've edited them and want git to surface the collisions instead, merge upstream's history:
git fetch upstream
git switch -c update-engine
git merge upstream/main --allow-unrelated-histories # the flag is needed once, for template-derived repos
Keep your side of the files you own:
git checkout --ours README.md src/config/site.ts .gitignore
git add README.md src/config/site.ts .gitignore
[!warning] Then check your vault With unrelated histories git has no record that you deleted the template's sample notes, so it treats them as new files and puts them back into
content/— quietly, with no conflict to alert you. Your own notes aren't overwritten, but the samples return.
git diff --name-only --diff-filter=A HEAD -- content # what the merge would add
git diff --name-only --diff-filter=A HEAD -- content | xargs -r git rm -q -f --
The engine-only route above has none of this exposure, which is why it's the default.