Git 错误
50 个错误
Git 常见错误排查手册:合并冲突、误提交、分支丢失等场景的恢复命令与预防方法。
50 / 50
- 1
fatal: 不 git 仓库
你 ran git command in directory 那个 isn't 内部 git 仓库 — 那里's 否 `.git` folder in 这个 or 任何 parent directory.
- 2
合并 Conflict
Git 停止 mid-合并因为两者都分支编辑相同行 — 你必须 manually 选择哪个 version 到 keep.
- 3
推送拒绝
你的推送是拒绝因为 remote 分支有 newer 提交 — 你需要到拉取 and integrate 它们首先.
- 4
Detached HEAD
你're 工作 on 提交 directly, 不分支 — 任何提交你制作 won't belong 到任何分支 and 能是 lost.
- 5
分支做不 Exist
你 referenced 分支 name 那个 git doesn't know 关于 — 它 doesn't exist locally or hasn't 是获取从 remote.
- 6
Uncommitted 更改
Git 停止你因为切换分支 or pulling 会 overwrite 更改你 haven't committed yet.
- 7
无到提交
你 tried 到提交, 但那里是否 staged 更改 — 你的工作树 matches 最后提交.
- 8
Pathspec 做不 Match
你 referenced file 那个 Git cannot 查找 — 它做不 exist in 工作 directory or 是不 tracked.
- 9
非-快-向前推送
你的局部 and remote 分支有 diverged — remote 有提交你做不有, and 你有提交它做不有.
- 10
局部更改会是 Overwritten
切换分支会 overwrite 你的 uncommitted 更改, 所以 Git 停止到 protect 你的工作.
- 11
Refusing 到合并 Unrelated Histories
你是 trying 到合并 two 仓库那个是创建 independently and share 否常见 ancestor.
- 12
Unmerged Files
合并 or rebase 是 in progress 使用 unresolved conflicts — 你必须 resolve 它们之前 committing.
- 13
坏对象引用
提交 hash, 分支, or 标签你 referenced 做不 exist or 是 corrupted.
- 14
Resolve 你的 Current 索引首先
上一个合并 or rebase 左 conflicts unresolved — 你必须 resolve or abort 之前开始新操作.
- 15
Permission 拒绝 (Publickey)
你的 SSH 键是不配置正确地 or 是不 associated 使用你的 GitHub account, 所以 remote 拒绝你的连接.
- 16
Remote Already Exists
remote 使用 name 你 specified (e.g. 原点) 是 already 配置 — 你 cannot 添加它再次.
- 17
受保护分支推送失败
分支 (e.g. 主要) 是受保护 on remote — direct pushes 是不允许. 你必须 use 拉取请求.
- 18
Ambiguous 实参
name 你 provided matches 两者都分支/提交 and file — Git 做不 know 哪个你平均值.
- 19
Cannot 做 Soft Reset 使用 Paths
git reset --soft cannot 是 used 使用 individual file paths — 它仅工作 on 整个仓库.
- 20
Dirty 索引期间 Rebase
Git refuses 到开始 rebase 因为你有 uncommitted 更改那个会是 lost.
- 21
无添加到提交
那里是新 (untracked) files 那个有不是 staged — git 提交有无到提交.
- 22
能不查找 Remote Ref
你 referenced remote 分支那个做不 exist — 它可能不有是 pushed yet or 是删除.
- 23
Cannot Lock Ref
引用 lock 能不是获取 — 通常 due 到 stale lock file or corrupted ref 状态.
- 24
坏 Revision
revision specifier 你 used (e.g. HEAD~5) goes 超出开头的 history or 引用非-existent 提交.
- 25
无效对象 Name
HEAD 做不点到有效提交 — 大多数通常因为否提交有是制作 yet.
- 26
大 File 拒绝
file 你是 pushing 是也大 for remote (GitHub 限制 files 到 100 MB). 你需要 Git LFS or 到移除 file.
- 27
Author Identity 不配置
你有不配置你的 Git 用户.name and 用户.email, 所以 Git cannot attribute 提交到你.
- 28
Rebase Conflict 不 Resolved
期间 rebase, 提交能不是 applied due 到 conflict. 你必须 resolve 它, skip 它, or abort.
- 29
Stale Remote-Tracking 分支
你的局部分支有不是更新使用 latest remote 提交 — 你是后面 and 应该拉取.
- 30
Accidental Force 推送数据 Loss
force 推送到 shared 分支 overwrote 提交那个 others 有 pushed. overwritten 提交可能是 recoverable.
- 31
git stash pop 冲突
你执行了 git stash pop,但暂存的修改与暂存后新增的修改产生了冲突 —— git 停止操作并在工作区中留下冲突标记。
- 32
git checkout:路径未匹配
你让 git checkout 切换到一个不存在的文件或分支 —— git 报告 'pathspec did not match any file(s) known to git'。
- 33
git rebase:无法变基到不相关的历史
你尝试变基到一个与当前分支没有共同提交历史的分支 —— git 阻止此操作以防止丢失提交。
- 34
git cherry-pick:提交为空
你拣选了一个修改已存在于当前分支的提交 —— git 报告提交为空或无操作。
- 35
git submodule update 失败:找不到仓库
你运行了 git submodule update,但 git 无法找到或获取某个子模块仓库 —— 远程 URL 错误或提交缺失。
- 36
git reflog:条目已过期并被清理
你尝试通过 git reflog 恢复提交,但该条目已被 git gc 清理 —— 提交哈希不再存在于 reflog 中。
- 37
git gc:松散对象过多错误
你运行 git gc 但失败了 —— 仓库积累了太多松散对象,打包它们超出了可用内存或磁盘空间。
- 38
git hook:权限不足或解释器错误
你的 .git/hooks/ 中的 git hook 没有运行 —— 文件不可执行或 shebang 行指向不存在的解释器。
- 39
git config:键名格式无效
你传给 git config 的键格式错误 —— 键必须遵循 section.subsection.variable 格式且使用有效字符。
- 40
gitattributes:无效的模式或属性
你的 .gitattributes 文件有一行模式格式错误或属性名拼写错误 —— git 会警告或忽略该条目。
- 41
gitignore:模式未按预期匹配
你在 .gitignore 中添加了模式,但文件仍被跟踪 —— 模式语法或锚定方式与文件路径不匹配。
- 42
git merge:指定的合并策略无效
你给 git merge -s 传了一个无效的合并策略 —— 只有 recursive、ort、resolve、ours、theirs、subtree 是内置策略。
- 43
git tag:标签名格式无效
你尝试创建的标签名包含空格、冒号或其他禁止字符 —— git 将其拒绝为无效引用名。
- 44
意外提交到了错误的分支
你将工作提交到了错误的分支 —— 提交在 main 上但应该在功能分支上,你需要安全地重新定位它。
- 45
强制推送后远程跟踪分支过期
队友强制推送了共享分支,你的本地远程跟踪引用仍指向旧历史 —— 拉取时产生冲突或重复提交。
- 46
变基与合并混淆
你变基了但本意是合并(或相反),产生了线性历史而非合并提交 —— 队友可能看到被重写的提交。
- 47
git reset --hard 导致数据丢失
你运行了 git reset --hard 并丢失了未提交的工作区修改 —— 修改未被暂存或提交,已从工作区消失。
- 48
git pull 静默创建了合并提交
你运行了 git pull 并得到了不期望的合并提交 —— 默认拉取策略执行了合并而非快进或变基。
- 49
变基后的孤立提交
你变基后原始的变基前提交变为孤立的 —— 它们存在于对象存储中但没有分支或标签指向它们。
- 50
git am:补丁格式损坏
你用损坏或格式错误的 mbox 补丁文件运行了 git am —— git 无法解析提交元数据或 diff 内容。
未找到相关错误。