Files
shizhui_website/docs/DEVELOP.md
ShiZhui 2ebabcf276
All checks were successful
Build and Deploy / build-deploy (push) Successful in 26s
docs: 新增日常开发流程文档(多机协作/凭据/自检)
2026-06-16 15:26:37 +08:00

2.5 KiB
Raw Blame History

日常开发流程

本网站采用「本地开发 → 推送 Gitea → 自动构建部署」的流程。 Gitea 远端是必须的:推送上去才会触发自动部署、更新线上网站。

一、Git 远端

  • 远端名:gitea
  • 地址:http://8.137.165.96:3000/shizhui/shizhui_website.git
  • 本地 main 已跟踪 gitea/main

二、日常流程(同一台电脑)

# 1. 开工前先拉最新(同步其他设备 / CMS 在线编辑的改动)
git pull

# 2. 改代码 …… 本地预览
npm run dev        # http://localhost:4321

# 3. 构建自测可选CI 也会构建)
npm run build

# 4. 提交并推送 → 自动触发构建部署
git add -A
git commit -m "说明本次改动"
git push

推送后约 30~60 秒Gitea Actions 自动完成构建并发布到 /var/www/shizhui 线上网站随即更新。

三、换一台新电脑开发

git clone http://8.137.165.96:3000/shizhui/shizhui_website.git
cd shizhui_website
npm install
# 之后照「日常流程」即可

四、Git 凭据(重要)

远端走 HTTPpush/pull 需要 Gitea 账号密码(用户 shizhuideveloper)。 为避免每次输入,二选一:

方式 A缓存凭据推荐简单

git config --global credential.helper store
# 第一次 push 时输入一次账号密码,之后会记住

方式 B在 URL 里带用户名(仍会提示输密码)

git remote set-url gitea http://shizhui@8.137.165.96:3000/shizhui/shizhui_website.git

注意:credential.helper store 会把密码明文存到 ~/.git-credentials 个人电脑可接受;公用电脑慎用。

五、多设备协作的纪律

  • 开工先 git pull,完工再 git push
  • 这样本地、其他电脑、CMS 在线编辑三方都能和谐共存。
  • 若 push 被拒(提示 rejected / non-fast-forwardgit pull --rebase 再 push。

六、备案完成后

域名 ICP 备案通过后,可把访问与远端从 IP 切回域名:

七、状态自检(怀疑线上与代码不一致时)

# 本地与远端是否一致(输出为空即一致)
git fetch gitea && git log gitea/main..main --oneline

# 线上标题是否为最新
curl -s http://8.137.165.96:8080/ | grep -o "<title>[^<]*</title>"