npx claudepluginhub an8079/take-skillsThis skill uses the workspace's default tool permissions.
> Git出问题了别慌!这个skill帮你诊断并修复所有常见Git疑难杂症。
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
Git出问题了别慌!这个skill帮你诊断并修复所有常见Git疑难杂症。
主要使用 exec 工具执行Git命令
识别:
<<<<<<< HEAD
当前分支的内容
=======
incoming分支的内容
>>>>>>> feature-branch
解决方法(三步走):
步骤1:查看冲突文件
git status # 列出所有冲突文件
git diff --name-only --diff-filter=U # 仅列出有冲突的文件
步骤2:手动解决冲突
编辑冲突文件,保留需要的部分,删除 <<<<<<<、=======、>>>>>>> 标记
步骤3:标记解决完成
git add <冲突文件>
git commit -m "fix: resolve merge conflict in XXX"
快捷工具:
# 用ours/theirs快速选择
git checkout --ours <file> # 保留当前分支版本
git checkout --theirs <file> # 保留合并分支版本
# 或用git checkout的保留策略
git merge -X ours <branch> # 自动用ours策略合并
git merge -X theirs <branch> # 自动用theirs策略合并
场景A:还没push,想重置本地
# 回退最近1次提交,保留改动
git reset --soft HEAD~1
# 回退最近1次提交,不保留改动(危险!)
git reset --hard HEAD~1
# 回退到指定commit
git reset --hard <commit-hash>
场景B:已经push了,想撤销
# 安全撤销:创建新提交来"反做"指定提交
git revert <commit-hash>
# 撤销最近1次提交
git revert HEAD
场景C:想回到某个tag
git reset --hard v1.0.0
git push --force origin <branch>
# 找到丢失分支的commit
git reflog
# 输出示例:
# abc1234 HEAD@{0}: checkout: moving from feature-x to main
# def5678 HEAD@{1}: commit: add new feature
# 恢复分支
git checkout -b <分支名> <commit-hash>
# 示例:
git checkout -b feature-x def5678
或者用 HEAD@{n} 直接恢复:
git checkout -b recovered-branch HEAD@{5}
停在了冲突点:
# 解决完冲突后
git add .
git rebase --continue
# 想放弃rebase,恢复原状
git rebase --abort
已经手动reset了?用reflog恢复:
git reflog | grep rebase
git reset --hard ORIG_HEAD
# 暂存当前改动
git stash
git stash save "临时stash: XXX改动"
# 查看暂存列表
git stash list
# 恢复最新stash
git stash pop
# 恢复指定stash
git stash apply stash@{0}
# 删除stash
git stash drop stash@{0}
# 撤销单个文件
git checkout -- <file>
git restore <file> # 新语法
# 撤销所有未提交的文件
git checkout -- .
git restore .
原因:远程有更新的提交
解决方法:
# 方法1:先拉取再push
git pull --rebase origin <branch>
git push origin <branch>
# 方法2:强制push(小心!)
git push --force origin <branch>
# 简洁日志
git log --oneline -10
# 图形化分支
git log --graph --oneline --all
# 查找特定内容
git log -S "关键词" --oneline
# 查看某个文件的历史
git log -p <file>
# 找出谁改了某行
git blame <file>
| 操作 | 危险等级 | 恢复方式 |
|---|---|---|
git reset --hard | 🔴 高 | git reflog 恢复 |
git push --force | 🔴 高 | git reflog + 远程恢复 |
git checkout . | 🟡 中 | 无法恢复 |
git clean -fd | 🔴 高 | 无法恢复(做好备份) |
最佳实践:危险操作前先 git branch backup 创建备份分支