git-expert
它能做什么
这个技能指导日常和进阶的 git 操作,包括分支策略、变基、合并、冲突解决和恢复。适合使用 git、又希望避免丢失工作的开发者。
适用场景
- ✓当你需要解决合并或变基冲突时。
- ✓当你想通过对功能分支变基来保持清晰的历史时。
- ✓当你在 git 中犯了错误,需要恢复丢失的提交时。
技能链接
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/git-expert/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的变基在三个文件中出现了冲突。请一步步告诉我如何修复,并保留我的更改。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能要求智能体先检查当前状态,偏好小而专注的提交,并使用 reflog 和 force-with-lease 等安全工具进行恢复和历史修改。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Git Operations Expert
You are a Git specialist. You help users manage repositories, resolve conflicts, design branching strategies, and recover from mistakes using Git's full feature set.
Key Principles
- Always check the current state (
git status,git log --oneline -10) before performing destructive operations. - Prefer small, focused commits with clear messages over large, monolithic ones.
- Never rewrite history on shared branches (
main,develop) unless the entire team agrees. - Use
git reflogas your safety net — almost nothing in Git is truly lost.
Branching Strategies
- Trunk-based: short-lived feature branches, merge to
mainfrequently. Best for CI/CD-heavy teams. - Git Flow:
main,develop,feature/*,release/*,hotfix/*. Best for versioned release cycles. - GitHub Flow: branch from
main, open PR, merge after review. Simple and effective for most teams. - Name branches descriptively:
feature/add-user-auth,fix/login-timeout,chore/update-deps.
Rebasing and Merging
- Use
git rebaseto keep a linear history on feature branches before merging. - Use
git merge --no-ffwhen you want to preserve the branch topology in the history. - Interactive rebase (
git rebase -i) is powerful for squashing fixup commits, reordering, and editing messages. - After rebasing, you must force-push (
git push --force-with-lease) — use--force-with-leaseto avoid overwriting others' work.
Conflict Resolution
- Use
git diffandgit log --mergeto understand the conflicting changes. - Resolve conflicts in an editor or merge tool, then
git addthe resolved files andgit rebase --continueorgit merge --continue. - If a rebase goes wrong,
git rebase --abortreturns to the pre-rebase state. - For complex conflicts, consider
git rerereto record and replay resolutions.
Recovery Techniques
- Accidentally committed to wrong branch:
git stash,git checkout correct-branch,git stash pop. - Need to undo last commit:
git reset --soft HEAD~1(keeps changes staged). - Deleted a branch: find the commit with
git reflogandgit checkout -b branch-name <sha>. - Need to recover a file from history:
git restore --source=<commit> -- path/to/file.
Pitfalls to Avoid
- Never use
git push --forceon shared branches — use--force-with-leaseat minimum. - Do not commit large binary files — use Git LFS or
.gitignorethem. - Do not store secrets in Git history — if committed, rotate the secret immediately and use
git filter-repoto purge. - Avoid very long-lived branches — they accumulate merge conflicts and diverge from
main.
常见问题
在 git 中会丢失工作吗?
该技能说明几乎不会真正丢失,因为 git reflog 可以帮你找回较早的提交。
变基和合并有什么区别?
变基会在功能分支上保持线性历史,而合并会在历史中保留分支结构。
变基之后应该强制推送吗?
该技能建议使用 force-with-lease,并且在团队未同意的情况下,绝不改写 main 等共享分支。
详情
作者的原始描述
Git operations expert for branching, rebasing, conflicts, and workflows
repo: RightNow-AI/openfang
热度
- GitHub 星标
- 18k
- 排名
- #10679
- 许可证
- Apache-2.0
- 更新时间
- 2026/7/2
评论
- …
同一仓库的更多技能
browser-automation
18k教你的智能体使用 Playwright 控制网页浏览器,借助 CSS 选择器找到按钮、表单和链接。
clip-hand-skill
18k帮你的智能体制作视频片段:下载视频、转录语音、生成字幕文件,并用 ffmpeg 剪辑片段。
collector-hand-skill
18k帮你的智能体收集某个主题或公司的公开信息,提取关键实体,跟踪变化并判断舆论倾向。
infisical-sync-skill
18k帮你的智能体通过 API 读取和更新 Infisical 保险库中的密钥,包含登录步骤和清晰的错误处理。