siyuan-backup-sync
Skill1 starsChanged 14 days agoMITView on GitHub
Git backup/sync workflow for the SiYuan data repository (70asunflower/siyuan-backup). Use when committing/pushing the siyuan data repo or fixing a blocked push. Triggers: 思源备份, 思源同步, 笔记备份, 思源 git, 仓库同步. Covers the gh-credential push command, LFS quota awareness, the mandatory 'close SiYuan before git' rule, the temp/install/*.exe .gitignore, and the plumbing-based history cleanup when a large installer accidentally got committed and blocks the push (GitHub GH001 >100MB).
- Deletes or force-pushes
- Commits and pushes
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- notion-im-helper/CLAUDE.mdCLAUDE.md
- 3d-printing-cad-designSkill
- agent-skills-syncSkill
- captain-resourceSkill
- csdn-publish-mcpSkill
- deep-research-report-pipelineSkill
- doc-plain-zhSkill
- feishu-bot-configSkill
- first-shotSkill
- investment-analysisSkill
- layoutfixSkill
- md2docx-formalSkill
- md-to-70asunflower-latexSkill
- multi-publish-mcpSkill
- notebook-patchingSkill
- notion-im-helperSkill
- paper-figuresSkill
- paper-reviewSkill
- paper-writingSkill
- project-initSkill
- project-reviewSkill
- siyuan-kernel-opsSkill
- siyuan-markdown-formula-formatterSkill
- snapSkill
- strict-docx-auditSkill
- trek-mcp-opsSkill
- visual-diagramsSkill
- weekreportSkill
- xhs-pipelineSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 36
Only temp/*.exe and *.db are LFS.
- Very specific: line 68
Keep backup-before-cleanup until the user confirms the push succeeded.
- Distinctive: line 74
Don't git push --force published history.
- Very specific: line 76
Always verify git rev-list --left-right --count origin/main...HEAD shows 0 0 after a successful push.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SiYuan Backup / Git Sync
Repo: D:\MyData\Warehouse\siyuan-backup → remote https://github.com/70asunflower/siyuan-backup.git.
This is the user's personal note backup — treat it as precious. Least-surprise, never force-push published history.
0. MANDATORY before ANY git operation
Close SiYuan first. It holds a SQLite write lock; committing while it's open risks a corrupted snapshot. Wait for the user to close it (don't kill it yourself — that's a state-changing op needing explicit consent).
1. Safe commit scope
Commit only:
data/(notes + attached assets)history/(snapshots)conf/conf.json
Exclude (add to .gitignore):
.locktemp/queue/temp/*.db-shm,temp/*.db-waltemp/*.db(mutates live; skip to avoid an inconsistent in-flight snapshot)
2. Push command (interactive creds are disabled in this env)
git -c credential.helper="!gh auth git-credential" pushgh is already logged in as 70asunflower. Plain git push fails because terminal credential prompts are blocked.
3. LFS awareness
- LFS quota: 1 GB(2026-10 快照时 ~927 MB used——数值会漂移,用前
gh api现查)。Watch it. .sydata files are NOT LFS-tracked → safe to commit freely.- Only
temp/*.exeand*.dbare LFS. A fresh SiYuan installer (siyuan-3.7.x-win.exe, ~200 MB) is NOT auto-LFS and will blow GitHub's 100 MB hard limit.
4. Prevent installer commits (.gitignore)
temp/install/*.exe
!temp/install/siyuan-3.7.0-win.exe # keep the LFS-tracked oneSiYuan's own backup script does git add -A, which would re-commit installers without this rule.
5. Fix a blocked push (GH001: >100 MB file in history)
Symptom: push rejected because an old (unpushed) commit contains a big temp/install/*.exe.
Strategy — rewrite only the unpushed range origin/main..HEAD; keep all already-published history hashes unchanged → push stays a fast-forward (no force-push, cloud safe).
Steps (plumbing, never touches the working tree — safe while SiYuan is open):
# 1. snapshot safety branch (local only, optional but recommended)
git branch backup-before-cleanup
# 2. for EACH commit in the range that contains the blob, rewrite its tree
# without the exe, using a throwaway index:
GIT_INDEX_FILE=/tmp/idx git read-tree <rev>^{tree}
GIT_INDEX_FILE=/tmp/idx git rm --cached --ignore-unmatch temp/install/siyuan-3.7.1-win.exe
newtree=$(GIT_INDEX_FILE=/tmp/idx git write-tree)
newrev=$(git commit-tree $newtree -p <parent> -m "<msg>")
git update-ref refs/heads/main $newrev
# 3. repeat for every commit that carries the blob (a child commit's tree
# ALSO contains it if it was built on top of the tainted one!)⚠️ Lessons (easy to get wrong):
- The blob must be stripped from every commit tree in the range that contains it — not just the one that first added it. Child commits inherit the tainted tree.
- Plumbing rewrites only the
mainref and does not update the real index. Before committing anything else, rungit reset --mixed <clean-rev>so the index matches, or you'll re-add the exe. - Keep
backup-before-cleanupuntil the user confirms the push succeeded.
Then push: git -c credential.helper="!gh auth git-credential" push (fast-forward).
To reclaim the ~209 MB the old branch holds in .git: git branch -D backup-before-cleanup && git gc --prune=now (only after success + user OK).
6. Gotchas
- Don't
git push --forcepublished history. git filter-branchrefuses on a dirty tree (SiYuan leaves 500+ modified files) → use the plumbing approach above instead.- Always verify
git rev-list --left-right --count origin/main...HEADshows0 0after a successful push. - Device rule: only edit SiYuan on one machine at a time (workstation vs home PC) to avoid sync conflicts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

