一个全局版 Git 提交记录器:每次 git commit 成功后,自动把提交记录同步到 Obsidian Vault。
.
├── config.example.json
├── git-recorder.sh
├── install.sh
├── post-commit
├── post-merge
└── post-rewrite
安装后会在你的 Vault 中生成:
Git Records/
├── README.md
├── Daily/
│ └── 2026/
│ └── 06/
│ └── 2026-06-29.md
└── Repos/
└── repo-name/
├── README.md
└── Commits/
└── 2026/
└── 06/
└── 2026-06-29/
└── abc1234.md
设计思路:
Daily/:按天汇总所有仓库提交,适合日报、周报、复盘。Repos/:按仓库沉淀提交详情,适合回溯项目演进。- 每个 commit 一个独立 Markdown,方便 Obsidian 双链、搜索和标签管理。
chmod +x install.sh
./install.sh --vault "/path/to/your/ObsidianVault"安装脚本会:
- 复制
git-recorder.sh到~/.config/git-recorder/git-recorder.sh - 复制 hooks 到
~/.config/git/hooks/ - 生成
~/.config/git-recorder/config.json - 设置全局 Git hooks:
git config --global core.hooksPath ~/.config/git/hooks配置文件位置:
~/.config/git-recorder/config.json示例:
{
"obsidianVault": "/Users/YOUR_NAME/Documents/Obsidian",
"rootDir": "Git Records",
"includeDiff": true,
"maxDiffLines": 300,
"repoNameStrategy": "directory",
"ignoreRepos": [],
"ignorePaths": []
}字段说明:
| 字段 | 说明 |
|---|---|
obsidianVault |
Obsidian Vault 根目录 |
rootDir |
Git 记录根目录,默认 Git Records |
includeDiff |
是否记录 diff 摘要 |
maxDiffLines |
diff 最多记录行数 |
repoNameStrategy |
directory 使用目录名;remote 使用远程仓库名 |
ignoreRepos |
忽略仓库名或仓库绝对路径 |
ignorePaths |
忽略某些路径下的仓库 |
每次 git commit 成功后触发,写入 commit Markdown,并更新 Daily / Repo 索引。
用于 git commit --amend、git rebase 等重写场景。当前 MVP 只写日志,不生成详细重写记录。
用于 git merge / git pull 后触发。当前 MVP 只写日志,不生成详细 merge 记录。
全局 hook 会在执行记录器后,尝试执行当前仓库的本地扩展 hook:
.git/hooks/post-commit.local
.git/hooks/post-rewrite.local
.git/hooks/post-merge.local
如果某个项目需要自己的 hook 逻辑,建议放到这些 .local 文件里,避免和全局 core.hooksPath 冲突。
进入任意 Git 仓库后执行:
~/.config/git-recorder/git-recorder.sh post-commit如果配置正确,会在 Obsidian Vault 的 Git Records/ 下生成记录。
查看日志:
tail -f ~/.config/git-recorder/recorder.log取消全局 hooks:
git config --global --unset core.hooksPath删除记录器文件:
rm -rf ~/.config/git-recorder如果 hooks 目录只用于这个工具,也可以删除:
rm -rf ~/.config/git/hooks注意:删除前请确认 ~/.config/git/hooks 没有其他你仍然需要的 hook。