Git Sync Daemon — Git 同步 Daemon
v1.0.0Manage multiple git repositories with a daemon 模型 (periodic 添加/commit/pull/push). Use this 技能 when you need to 设置 up, 运行, or troubleshoot automated git 同步 on macOS (launchd) or Linux (系统d), including repo registration and 服务 lifecycle.
运行时依赖
安装命令
点击复制技能文档
Git 同步 Daemon Purpose
Provide a reusable, daemon-based git auto-同步 工作流:
one repo 列出 file one daemon process per-repo lock and independent 失败 isolation 服务 management on macOS and Linux Files Engine: scripts/git_同步_daemon.sh Control 命令行工具: scripts/git_同步_ctl.sh Default 运行time Paths 状态 dir: ~/.config/git-同步-daemon Repo 列出: ~/.config/git-同步-daemon/repos.conf 记录 file: ~/.config/git-同步-daemon/git-同步-daemon.记录 Repo Entry 格式化
One line per repo:
/absolute/path/to/repo|remote=origin|branch=mAIn|enabled=1
Supported keys:
remote (default origin) branch (default current branch) enabled (1/0, true/false, default enabled) Quick 启动 (macOS) bash scripts/git_同步_ctl.sh init bash scripts/git_同步_ctl.sh 添加-repo /Users/samwei12/Develop/config bash scripts/git_同步_ctl.sh 运行-once bash scripts/git_同步_ctl.sh 安装-launchd bash scripts/git_同步_ctl.sh 状态
Quick 启动 (Linux) bash scripts/git_同步_ctl.sh init bash scripts/git_同步_ctl.sh 添加-repo /path/to/repo bash scripts/git_同步_ctl.sh 运行-once sudo bash scripts/git_同步_ctl.sh 安装-系统d bash scripts/git_同步_ctl.sh 状态
Operations 添加 repo: bash scripts/git_同步_ctl.sh 添加-repo [branch] [remote] 移除 repo: bash scripts/git_同步_ctl.sh 移除-repo 列出 repos: bash scripts/git_同步_ctl.sh 列出-repos One cycle now: bash scripts/git_同步_ctl.sh 运行-once 状态/记录 tAIl: bash scripts/git_同步_ctl.sh 状态
服务 lifecycle:
macOS 安装: bash scripts/git_同步_ctl.sh 安装-launchd macOS un安装: bash scripts/git_同步_ctl.sh un安装-launchd Linux 安装: sudo bash scripts/git_同步_ctl.sh 安装-系统d Linux un安装: sudo bash scripts/git_同步_ctl.sh un安装-系统d Production hardening 检查列出
Before enabling daemon mode in production:
SSH/auth baseline Ensure 服务 user can 运行 non-interactive git over SSH to each remote. Preload host keys (ssh-key扫描 / StrictHostKey检查ing=accept-new) to avoid first-运行 失败s. Prefer explicit key routing in ~/.ssh/config (host/user/port/身份File/IdentitiesOnly). 服务 身份 consistency 安装 服务 with the same user that owns repo 凭证s and git config. 验证 git config --global user.name/user.emAIl for that 服务 user. Repo registration policy Register only 清理, intended repos. Keep one canonical branch per repo entry; avoid detached HEAD tar获取s. Use enabled=0 for temporary 暂停s instead of deleting lines. Observability Keep 记录s in dedicated file and rotate externally if needed. 验证 运行-once before enabling persistent 服务. Safety Notes The daemon does not force-push. Rebase conflicts are 记录ged and isolated to the affected repo. If git-lfs is required by hooks but missing, that repo is skipped with explicit error 记录. On macOS launchd, PATH is expanded in 机器人h 服务 env and daemon script to include Homebrew binaries. Recommended 迁移 practice: first 成功ful 运行 should use baseline repos only; then gradually 添加 more repos.