Git“配对损坏”是怎么回事?和“未知”;状态的含义以及它们何时发生?
git diff
中的某些选项(例如 --name-status
)会导致在文件名旁边输出状态字母。他们是:
A、C、D、M、R、T、U、X、B
……它们的意思是
添加 (A)、复制 (C)、删除 (D)、修改 (M)、重命名 (R)、 类型(即常规文件、符号链接、子模块等)已更改 (T), 未合并 (U)、未知 (X) 或配对损坏 (B)。
问题:X
和 B
状态应该如何解释,以及哪些情况会导致它们的出现?您能否提供导致此类状态出现在 git-diff 输出中的一系列步骤,以及可能的修复方法?
Some options in git diff
, for instance --name-status
, cause the output of a status letter next to a file name. They are:
A, C, D, M, R, T, U, X, B
… and they mean
Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R),
type (i.e. regular file, symlink, submodule, …) changed (T),
Unmerged (U), Unknown (X), or pairing Broken (B).
Question: how should the X
and B
statuses be interpreted, and which circumstances lead to their appearance? Can you provide a series of steps leading to such statuses appearing in the output of git-diff
, and possibly ways to fix them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
B
“断开对”状态永远不会直接出现在--name-status
输出中,它仅作为选项--diff-filter 的参数有用
当同时使用选项-B
(--break-rewrites
) 时。使用它作为过滤器可以选择至少已删除或更改一定比例内容的文件。这种“破坏”对于
--name-status
来说并不是很有用,因为“破坏”的目的主要是改变 diff 文本的生成方式:它消除了上下文中的上下文行(未更改的行)。 diff 输出,而不是生成 diff 算法碰巧找到的任何“随机”公共子序列所需的添加和删除行。X
“未知”状态实际上不应该出现。如果它确实出现,则意味着既没有取消合并、添加、删除、修改也没有更改其类型(实际上:未更改)的路径名意外地使其成为内部差异机制的核心;错误feeding unmodified还将生成 diffcore
。它似乎是一些旧的操作模式遗留下来的。
The
B
“broken pair” status never appears directly in--name-status
output, it is only useful as an argument to the option--diff-filter
when also using the option-B
(--break-rewrites
). Using it as a filter selects files that have had at least a certain percentage of their content deleted or changed.This “breaking” is not be terribly useful with
--name-status
since the point of “breaking” is mostly to change how the diff text is generated: it eliminates context lines (unchanged lines) from the diff output instead of generating the add and remove lines that would be required around whatever “random” common subsequences the diff algorithm happened to find.The
X
“unknown” status should never actually appear. If it does appear, it means a pathname that is neither unmerged, added, deleted, modified or had its type changed (effectively: unchanged) unexpectedly made it to the core of the internal diff machinery; the errorfeeding unmodified <pathname> to diffcore
will also be generated.It appears to be left over from some old mode of operation.