重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
git-2025-features by josiahsiegel/claude-plugin-marketplace
npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill git-2025-features📌 注意: 关于 Git 2.49+ 的详细功能(git-backfill、path-walk API、zlib-ng),请参阅 git-2-49-features.md 技能。
强制要求:在 Windows 上始终对文件路径使用反斜杠
在 Windows 上使用 Edit 或 Write 工具时,你必须在文件路径中使用反斜杠 (\),而不是正斜杠 (/)。
示例:
D:/repos/project/file.tsxD:\repos\project\file.tsx这适用于:
除非用户明确要求,否则切勿创建新的文档文件。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
主要新增功能: git-backfill、path-walk API、zlib-ng 性能提升、改进的增量压缩。
完整内容请参阅 git-2-49-features.md。
是什么: 新的引用存储格式,取代了松散的引用文件和 packed-refs。
优势:
迁移:
# 检查当前引用存储格式
git config core.refStorage
# 迁移到 reftables
git refs migrate --ref-storage=reftables
# 验证迁移
git fsck --full
git log --oneline -5
# 如果需要回滚(在关键操作之前)
git refs migrate --ref-storage=files
何时使用:
Git 2.48:
Git 2.49:
自动受益于:
是什么: 仅检出仓库中的文件子集。
使用场景:
锥形模式 (默认 - 推荐):
# 使用稀疏检出克隆
git clone --filter=blob:none --sparse <repo-url>
cd <repo>
# 以锥形模式初始化稀疏检出
git sparse-checkout init --cone
# 添加要检出的目录
git sparse-checkout set src/api src/shared docs
# 添加更多目录
git sparse-checkout add tests/integration
# 查看当前模式
git sparse-checkout list
# 检查将匹配的内容
git sparse-checkout check-rules src/api/users.ts
# 禁用稀疏检出
git sparse-checkout disable
高级模式 (非锥形模式):
# 启用模式匹配
git sparse-checkout init --no-cone
# 添加模式(每行一个)
git sparse-checkout set \
"*.md" \
"src/api/*" \
"!src/api/legacy/*"
# 从文件读取模式
git sparse-checkout set --stdin < patterns.txt
重新应用规则:
# 在合并/rebase 后产生了不需要的文件时
git sparse-checkout reapply
是什么: 克隆仓库时最初不下载所有对象。
过滤器:
用法:
# 克隆时不包含 blob(按需获取)
git clone --filter=blob:none <repo-url>
# 克隆时不包含大文件
git clone --filter=blob:limit=10m <repo-url>
# 与稀疏检出结合使用
git clone --filter=blob:none --sparse <repo-url>
cd <repo>
git sparse-checkout set src/api
# 将现有仓库转换为部分克隆
git config extensions.partialClone origin
git config remote.origin.promisor true
git fetch --filter=blob:none
# 预取所有缺失的对象
git fetch --unshallow
结合部分克隆 + 稀疏检出:
# 终极效率:仅获取特定目录的对象
git clone --filter=blob:none --sparse <repo-url>
cd <repo>
git sparse-checkout set --cone src/api
git checkout main
# 结果:仅拥有 src/api 的对象
检查 promisor 对象:
# 验证部分克隆状态
git config extensions.partialClone
# 查看 promisor 包文件
ls -lah .git/objects/pack/*.promisor
# 强制获取特定对象
git rev-list --objects --missing=print HEAD | grep "^?"
是什么: 从一个仓库创建多个工作目录。
优势:
基本操作:
# 列出工作树
git worktree list
# 为现有分支创建工作树
git worktree add ../project-feature feature-branch
# 使用新分支创建工作树
git worktree add -b new-feature ../project-new-feature
# 从远程分支创建工作树
git worktree add ../project-fix origin/fix-bug
# 移除工作树
git worktree remove ../project-feature
# 清理过时的工作树引用
git worktree prune
高级模式:
# 用于 PR 审查的工作树,同时进行编码
git worktree add ../myproject-pr-123 origin/pull/123/head
cd ../myproject-pr-123
# 在单独的目录中审查 PR
cd -
# 在主工作树中继续编码
# 用于热修复的工作树
git worktree add --detach ../myproject-hotfix v1.2.3
cd ../myproject-hotfix
# 进行热修复
git switch -c hotfix/security-patch
git commit -am "fix: patch vulnerability"
git push -u origin hotfix/security-patch
# 工作树组织
mkdir -p ~/worktrees/myproject
git worktree add ~/worktrees/myproject/feature-a -b feature-a
git worktree add ~/worktrees/myproject/feature-b -b feature-b
git worktree add ~/worktrees/myproject/pr-review origin/pull/42/head
最佳实践:
~/projects/
myproject/ # 主工作树
myproject-feature/ # 功能工作树
myproject-review/ # 审查工作树
2. 定期清理:
# 移除已合并的工作树
git worktree list | grep feature | while read wt branch commit; do
if git branch --merged | grep -q "$branch"; then
git worktree remove "$wt"
fi
done
3. 共享配置:
是什么: 用于优化超大型仓库的工具(由 Microsoft 开发)。
# 安装 scalar(随 Git 2.47+ 提供)
scalar register <path>
# 使用 scalar 优化克隆
scalar clone --branch main <repo-url>
# 自动启用:
# - 稀疏检出(锥形模式)
# - 部分克隆(blob:none)
# - 多包索引
# - 提交图
# - 后台维护
# 取消注册
scalar unregister <path>
# 删除仓库
scalar delete <path>
是什么: 在部分克隆中获取缺失对象的后台进程。
# 在后台获取缺失的 blob
git backfill
# 配置批处理大小
git backfill --min-batch-size=1000
# 遵循稀疏检出模式
git backfill --sparse
传统克隆:
git clone large-repo
# 大小:5GB,时间:10 分钟
稀疏检出:
git clone --sparse large-repo
git sparse-checkout set src/api
# 大小:500MB,时间:3 分钟
部分克隆:
git clone --filter=blob:none large-repo
# 大小:100MB,时间:1 分钟
部分克隆 + 稀疏检出:
git clone --filter=blob:none --sparse large-repo
git sparse-checkout set src/api
# 大小:50MB,时间:30 秒
稀疏检出:
部分克隆:
工作树:
结合所有功能:
稀疏检出不工作:
# 验证配置
git config core.sparseCheckout
git config core.sparseCheckoutCone
# 重新应用模式
git sparse-checkout reapply
# 检查模式
git sparse-checkout list
部分克隆中对象缺失:
# 获取特定对象
git fetch origin <commit>
# 获取所有缺失对象
git fetch --unshallow
# 验证 promisor 配置
git config extensions.partialClone
工作树问题:
# 工作树被锁定
git worktree unlock <path>
# 工作树损坏
git worktree remove --force <path>
git worktree prune
# 分支已被检出
git checkout --ignore-other-worktrees <branch>
从传统工作流迁移到优化工作流:
# 1. 当前的大型克隆
cd large-project
du -sh .git # 5GB
# 2. 创建优化的新克隆
cd ..
git clone --filter=blob:none --sparse large-project-new
cd large-project-new
git sparse-checkout set src/api src/shared
# 3. 验证大小
du -sh .git # 50MB
# 4. 切换工作流
cd ../large-project-new
# 5. 确认无误后删除旧克隆
rm -rf ../large-project
每周安装次数
62
仓库
GitHub 星标数
21
首次出现
2026年1月24日
安全审计
安装于
gemini-cli49
opencode48
codex46
cursor45
claude-code43
github-copilot42
📌 NOTE: For detailed Git 2.49+ features (git-backfill, path-walk API, zlib-ng), see git-2-49-features.md skill.
MANDATORY: Always Use Backslashes on Windows for File Paths
When using Edit or Write tools on Windows, you MUST use backslashes (\) in file paths, NOT forward slashes (/).
Examples:
D:/repos/project/file.tsxD:\repos\project\file.tsxThis applies to:
NEVER create new documentation files unless explicitly requested by the user.
Major additions: git-backfill, path-walk API, zlib-ng performance, improved delta compression.
See git-2-49-features.md for complete coverage.
What: New reference storage format replacing loose ref files and packed-refs.
Benefits:
Migration:
# Check current ref storage format
git config core.refStorage
# Migrate to reftables
git refs migrate --ref-storage=reftables
# Verify migration
git fsck --full
git log --oneline -5
# Roll back if needed (before critical operations)
git refs migrate --ref-storage=files
When to use:
Git 2.48:
Git 2.49:
Benefits automatically in:
What: Check out only a subset of files from repository.
Use cases:
Cone Mode (Default - Recommended):
# Clone with sparse-checkout
git clone --filter=blob:none --sparse <repo-url>
cd <repo>
# Initialize sparse-checkout in cone mode
git sparse-checkout init --cone
# Add directories to checkout
git sparse-checkout set src/api src/shared docs
# Add more directories
git sparse-checkout add tests/integration
# View current patterns
git sparse-checkout list
# Check what would be matched
git sparse-checkout check-rules src/api/users.ts
# Disable sparse-checkout
git sparse-checkout disable
Advanced Patterns (Non-Cone Mode):
# Enable pattern mode
git sparse-checkout init --no-cone
# Add patterns (one per line)
git sparse-checkout set \
"*.md" \
"src/api/*" \
"!src/api/legacy/*"
# Read patterns from file
git sparse-checkout set --stdin < patterns.txt
Reapply Rules:
# After merge/rebase that materialized unwanted files
git sparse-checkout reapply
What: Clone repository without downloading all objects initially.
Filters:
Usage:
# Clone without blobs (fetch on demand)
git clone --filter=blob:none <repo-url>
# Clone without large files
git clone --filter=blob:limit=10m <repo-url>
# Combine with sparse-checkout
git clone --filter=blob:none --sparse <repo-url>
cd <repo>
git sparse-checkout set src/api
# Convert existing repository to partial clone
git config extensions.partialClone origin
git config remote.origin.promisor true
git fetch --filter=blob:none
# Prefetch all missing objects
git fetch --unshallow
Combine Partial Clone + Sparse-Checkout:
# Ultimate efficiency: Only objects for specific directories
git clone --filter=blob:none --sparse <repo-url>
cd <repo>
git sparse-checkout set --cone src/api
git checkout main
# Result: Only have objects for src/api
Check promisor objects:
# Verify partial clone status
git config extensions.partialClone
# See promisor packfiles
ls -lah .git/objects/pack/*.promisor
# Force fetch specific object
git rev-list --objects --missing=print HEAD | grep "^?"
What: Multiple working directories from one repository.
Benefits:
Basic Operations:
# List worktrees
git worktree list
# Create worktree for existing branch
git worktree add ../project-feature feature-branch
# Create worktree with new branch
git worktree add -b new-feature ../project-new-feature
# Create worktree from remote branch
git worktree add ../project-fix origin/fix-bug
# Remove worktree
git worktree remove ../project-feature
# Clean up stale worktree references
git worktree prune
Advanced Patterns:
# Worktree for PR review while coding
git worktree add ../myproject-pr-123 origin/pull/123/head
cd ../myproject-pr-123
# Review PR in separate directory
cd -
# Continue coding in main worktree
# Worktree for hotfix
git worktree add --detach ../myproject-hotfix v1.2.3
cd ../myproject-hotfix
# Make hotfix
git switch -c hotfix/security-patch
git commit -am "fix: patch vulnerability"
git push -u origin hotfix/security-patch
# Worktree organization
mkdir -p ~/worktrees/myproject
git worktree add ~/worktrees/myproject/feature-a -b feature-a
git worktree add ~/worktrees/myproject/feature-b -b feature-b
git worktree add ~/worktrees/myproject/pr-review origin/pull/42/head
Best Practices:
~/projects/
myproject/ # Main worktree
myproject-feature/ # Feature worktree
myproject-review/ # Review worktree
2. Clean up regularly:
# Remove merged worktrees
git worktree list | grep feature | while read wt branch commit; do
if git branch --merged | grep -q "$branch"; then
git worktree remove "$wt"
fi
done
3. Shared configuration:
What: Tool for optimizing very large repositories (Microsoft-developed).
# Install scalar (comes with Git 2.47+)
scalar register <path>
# Clone with scalar optimizations
scalar clone --branch main <repo-url>
# Enables automatically:
# - Sparse-checkout (cone mode)
# - Partial clone (blob:none)
# - Multi-pack-index
# - Commit-graph
# - Background maintenance
# Unregister
scalar unregister <path>
# Delete repository
scalar delete <path>
What: Background process to fetch missing objects in partial clone.
# Fetch missing blobs in background
git backfill
# Configure batch size
git backfill --min-batch-size=1000
# Respect sparse-checkout patterns
git backfill --sparse
Traditional Clone:
git clone large-repo
# Size: 5GB, Time: 10 minutes
Sparse-Checkout:
git clone --sparse large-repo
git sparse-checkout set src/api
# Size: 500MB, Time: 3 minutes
Partial Clone:
git clone --filter=blob:none large-repo
# Size: 100MB, Time: 1 minute
Partial Clone + Sparse-Checkout:
git clone --filter=blob:none --sparse large-repo
git sparse-checkout set src/api
# Size: 50MB, Time: 30 seconds
Sparse-Checkout:
Partial Clone:
Worktrees:
Combine All:
Sparse-checkout not working:
# Verify configuration
git config core.sparseCheckout
git config core.sparseCheckoutCone
# Re-apply patterns
git sparse-checkout reapply
# Check patterns
git sparse-checkout list
Missing objects in partial clone:
# Fetch specific object
git fetch origin <commit>
# Fetch all missing
git fetch --unshallow
# Verify promisor config
git config extensions.partialClone
Worktree issues:
# Locked worktree
git worktree unlock <path>
# Corrupted worktree
git worktree remove --force <path>
git worktree prune
# Branch already checked out
git checkout --ignore-other-worktrees <branch>
From traditional to optimized workflow:
# 1. Current large clone
cd large-project
du -sh .git # 5GB
# 2. Create optimized new clone
cd ..
git clone --filter=blob:none --sparse large-project-new
cd large-project-new
git sparse-checkout set src/api src/shared
# 3. Verify size
du -sh .git # 50MB
# 4. Switch workflow
cd ../large-project-new
# 5. Delete old clone when comfortable
rm -rf ../large-project
Weekly Installs
62
Repository
GitHub Stars
21
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli49
opencode48
codex46
cursor45
claude-code43
github-copilot42
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
123,700 周安装