git-cloud-sync

Folder cloud sync: host any folder in a CNB or Gitee private repository to achieve bidirectional synchronization between multiple computers. Supports all file types and uses a pure Git-based approach for cross-device file syncing. Trigger keywords include “folder sync”, “sync files across computers”, “git sync”, and “cross-device sync”.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "git-cloud-sync" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-d771bcf1e8ca9d3af59f565ca5440ca3146247b9ca20fdf9cf4583ee982aeabc. Verify the upstream source and version against https://skillhub.cn/skills/user_90a020b6/erdong-git-cloud-sync before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Folder cloud sync: host any folder in a CNB or Gitee private repository to achieve bidirectional synchronization between multiple computers. Supports all file types and uses a pure Git-based approach for cross-device file syncing. Trigger keywords include “folder sync”, “sync files across computers”, “git sync”, and “cross-device sync”.

0 Downloads

Introduction source: third_party · user_90a020b6 · 1.1.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: git-cloud-sync
description: 文件夹云同步——把任何文件夹托管到 CNB 或 Gitee 私有仓库,实现多台电脑双向同步。不限文件类型、不限用途,纯 Git 方案。触发:用户说"文件夹同步""多台电脑同步文件""git同步""跨设备同步"。
slug: erdong-git-cloud-sync
displayName: 文件夹云同步——Git 双向同步
version: 1.1.0
summary: 通用文件夹 Git 双向同步方案。把任意文件夹托管到 CNB/Gitee 私有仓库,通过 git push/pull 在多台电脑间同步。不限文件类型、不限使用场景——代码片段、配置文件、笔记、项目草稿都能用。附同步脚本和冲突处理指南。
license: MIT
tags: ["同步", "git", "CNB", "Gitee", "多设备", "文件夹"]

文件夹云同步——Git 双向同步

一个文件夹,两台电脑,一个私有 Git 仓库——搞定。

适用场景

不限用途。能是一个文件夹、能用 git,就能同步:

  • 笔记库
  • 配置文件目录
  • 代码片段
  • 项目草稿
  • 任何你想在多台电脑之间保持一致的东西

文件大小有上限——Git 不适合同步视频和大尺寸图片(单文件 >100MB 会很慢)。大文件建议网盘,小文件和文本类同步用这个。

如何触发

你说的 我会做什么
"帮我设置文件夹同步""多台电脑同步文件" 按操作步骤引导你建仓库、推送、拉取
"帮我把笔记同步到另一台电脑" 同上 + 帮你选定同步目录
"帮我写个同步脚本" 直接提供 sync.sh,帮你改好路径
"同步出问题了,帮我看看" 先跑 status 诊断,再给修复建议
"我想定时自动同步" 帮你设置 cron / 任务计划
"帮我解决 git 冲突" 按冲突处理流程引导你手动解决
"迁移到新仓库" 帮你改 remote 地址
"我的灵台需要同步" 同上——灵台知识库就是一个文件夹,用这套方案直接同步

如果不确定怎么触发,直接说"我想让两台电脑上的同一个文件夹保持一致"——我会走完整流程。

架构

电脑 A                       电脑 B
┌──────┐                    ┌──────┐
│ 文件夹 │                    │ 文件夹 │
│ ~/x  │                    │ ~/x  │
└──┬───┘                    └──┬───┘
   │                           │
   │ git push/pull             │ git push/pull
   │                           │
   └─────────┬─────────────────┘
             ▼
     ┌──────────────┐
     │  CNB / Gitee │
     │  私有 Git 仓库 │
     └──────────────┘

不需要任何付费服务——免费私有 Git 仓库足够。

前置条件

  • 两台电脑,都装了 Git
  • 一个 CNB(cnb.cool)或 Gitee(gitee.com)账号

操作步骤

第一步:建中枢仓库

在 CNB 或 Gitee 上新建一个私有仓库。不要初始化 README——空仓库。

第二步:第一台电脑推送

cd /路径/到/你要同步的文件夹

git init
echo ".DS_Store\nThumbs.db\n__pycache__/\n*.pyc" > .gitignore
git add -A
git commit -m "init"
git branch -M main
git remote add origin <仓库地址>
git push -u origin main

第三步:另一台电脑拉取

git clone <仓库地址> /路径/到/本地文件夹

第四步:日常同步

cd /路径/到/文件夹

# 开始前拉最新
git pull --rebase

# 结束后推
git add -A && git commit -m "sync $(date +%F_%H%M)" && git push

自动化脚本

本 Skill 自带 sync.sh——直接下载放到 ~/ 或任意位置即可使用。

快速开始:

# 下载脚本(如果你已经安装了这个 Skill)
cp skills/git-cloud-sync/sync.sh ~/sync.sh
chmod +x ~/sync.sh

# 改一下同步目录(修改脚本顶部的 SYNC_DIR,或者用环境变量)
export SYNC_DIR="$HOME/你的文件夹"

# 试运行
bash ~/sync.sh status    # 查看同步状态
bash ~/sync.sh pull      # 只拉取
bash ~/sync.sh push      # 只推送
bash ~/sync.sh sync      # 先拉后推(默认)
bash ~/sync.sh sync -r   # 带自动重试(网络不稳定时推荐)
bash ~/sync.sh sync --retry 5  # 最多重试 5 次

脚本功能一览:

命令 作用 适用场景
sync 先拉取再推送(默认) 日常同步
pull 只拉取远程更新 开机后、开始工作前
push 只推送本地变更 关电脑前
status 查看本地/远程差异 排查问题
-r / --retry N 失败自动重试 网络不稳定时

定时执行建议:

# 每天早 9 点自动拉取(crontab -e)
0 9 * * * bash ~/sync.sh pull

# 每晚 22 点自动推送
0 22 * * * bash ~/sync.sh push -r

Windows 用户:用"任务计划程序"代替 cron;在 Git Bash 中运行或把脚本改写成 sync.bat。

冲突处理

两台电脑同时改了同一个文件:

cd /路径/到/文件夹
git pull --rebase
# 有冲突 → 打开冲突文件,手动保留正确内容,删掉 <<<<<<< >>>>>>> 标记
git add .
git rebase --continue
git push

减少冲突:在不同电脑上尽量编辑不同的文件。

预期输出示例

正常同步(无变更):

ℹ️  同步目录: /home/user/notes
ℹ️  远程仓库: https://cnb.cool/xxx/notes.git
ℹ️  第1步:拉取远程更新…
Already up to date.
✅ 同步完成——无本地变更需要推送

正常同步(有变更):

ℹ️  第1步:拉取远程更新…
Updating a1b2c3d..e4f5g6h
 笔记.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ℹ️  第2步:提交并推送本地变更…
[main f7a8b9c] sync 2026-07-30_1542
 1 file changed, 3 insertions(+), 1 deletion(-)
✅ 同步完成——拉取+推送均成功

网络失败(带重试):

ℹ️  第1步:拉取远程更新…
⚠️  第 1 次尝试失败,5秒后重试…(共 3 次)
⚠️  第 2 次尝试失败,5秒后重试…(共 3 次)
✅ 已拉取最新内容

冲突提示:

Auto-merging 笔记.md
CONFLICT (content): Merge conflict in 笔记.md
⚠️  拉取失败。可以用 --retry 启用自动重试。
(此时需手动解决冲突——见下方「冲突处理」)

注意事项

  1. 仓库设私有——这是你的个人文件
  2. 不要推敏感信息——密码、API Key、token 不要放进同步文件夹
  3. 大文件限制——Git 不适合同步 >100MB 的单文件或大量二进制文件
  4. .gitignore 按需调整——.DS_Store、Thumbs.db、缓存文件通常不需要同步
  5. 首次 push 大文件夹——如果文件夹已经很大,第一次 push 会慢,正常现象

🚫 常见错误与反模式

错误做法 为什么有问题 正确做法
把整个 C:\ 或 ~/ 建为 Git 仓库 文件太多、太大,push 会卡死,且极易泄露隐私 只同步需要多设备共享的具体文件夹
密码/Token/API Key 放在同步文件夹里 推到远程仓库后任何人都可能看到 敏感信息用环境变量或专门的密码管理器
在两台电脑上同时改同一个文件后直接 push 必然冲突,且可能丢内容 先 pull 再改;尽量在不同电脑上分工编辑不同文件
忘了改 SYNC_DIR 就直接跑脚本 脚本会提示"目录不存在" 先 export SYNC_DIR=你的路径 或修改脚本顶部
仓库不设私有 你的笔记/配置对所有人可见 建仓库时选"私有"(CNB/Gitee 都免费)
git push -f(强制推送) 会覆盖远程仓库,另一台电脑的变更直接丢失 永远不要 -f,用 pull --rebase 解决冲突
只在 A 电脑 push,B 电脑从不 pull B 电脑的内容越来越旧,改了什么都不知道 每次开始工作前先 pull,结束时再 push
同步大文件(视频、PSD、数据库文件) Git 无法高效处理二进制大文件,仓库会迅速膨胀 大文件用网盘(百度云/iCloud),文本用 Git

排障 FAQ

Q:push 报"rejected"? A:远程有你的本地没有的提交。先 git pull --rebase 再 push。

Q:文件夹有几千个文件,push 很慢? A:正常。Git 不适应大量小文件的首次上传。后续增量同步会很快。如果确实太多,考虑把不常改动的大批文件排除在 .gitignore 外。

Q:CNB / Gitee 选哪个? A:功能一样,都免费。CNB 国内速度更快,Gitee 社区更大。

Q:能同步到 GitHub 吗? A:可以,把仓库地址换成 GitHub 的。GitHub 在国内可能慢,建议用 CNB 或 Gitee。

Q:clone 时报"Permission denied"? A:两种情况:① SSH Key 没配——用 HTTPS 地址代替 SSH 地址,或在 CNB/Gitee 设置里加上你的 SSH 公钥;② 仓库是私有但没登录——确保已经在本机登录(git config --global credential.helper 检查)。

Q:同步后发现文件中文乱码? A:Windows 和 macOS/Linux 之间的编码差异。在你的 .gitignore 同级放一个 .gitattributes 文件,内容:* text=auto。已乱码的文件需要手动修复后重新 commit。

Q:想换一个仓库地址(从 Gitee 迁到 CNB)? A:git remote set-url origin <新地址>,然后 git push -u origin main。

Q:定时同步怎么设? A:Linux/macOS 用 crontab -e(见上方「定时执行建议」)。Windows 用"任务计划程序":新建任务→触发器→每天→操作→启动程序 C:\Program Files\Git\bin\bash.exe,参数 ~/sync.sh sync -r。

Q:会不会把别人的文件同步到我的仓库里? A:不会。私有仓库只有你自己和明确授权的人能访问。git pull 只从你的仓库拉取,不会混入别人的内容。

Q:.git 目录会不会越来越大? A:文本文件增量很小,几百篇笔记的 .git 通常 <50MB。但如果你频繁添加/删除大文件,可以定期 git gc --aggressive 清理。

不做什么

  1. 不限制同步什么——文件夹、代码、笔记、配置……都行
  2. 不自动同步——给脚本和排程建议,具体节奏你来定
  3. 不托管 Git 之外的同步方案(网盘、rsync 等各有适用场景,互不替代)

Current listing version

1.1.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value78/100

Highlights

  • 提供通用文件夹 Git 双向同步方案,适用于笔记、配置、代码等多设备同步场景
  • 逻辑完整,附带自动化脚本和冲突处理指南,形成闭环体验
Trigger Precision85/100

Highlights

  • 触发词覆盖合理且边界清晰,包含多种用户表达变体
  • skill_body 内进一步细化触发场景表格,提升触发准确性
Structure and Standards90/100

Highlights

  • 操作步骤分阶段清晰,含端到端示例和自动化脚本说明
  • frontmatter 完整,文档结构规范,单文件长度适中
Execution Reliability88/100

Highlights

  • 工具来源明确(Git + CNB/Gitee),参数正确
  • 覆盖主要异常场景(网络重试、冲突处理),避免强制推送等危险操作
Evidence Verifiability (mean of the first four)85/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • cnb.cool

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.