gpt4 book ai didi

git - 强制 git status 确认副本和类型更改

转载 作者:太空狗 更新时间:2023-10-29 14:31:53 25 4
gpt4 key购买 nike

git 中的状态码 'C' 和 'T' 是如何触发的?有人可以给我一组非常简单的命令来运行,这些命令将模拟所需的步骤,以便在我运行 git log --name-status 时看到上面的状态代码吗?我已尝试复制文件并更改已被跟踪的文件的扩展名类型,但它只是标记为已修改或已添加。

https://git-scm.com/docs/git-diff

Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, …​) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.

谢谢

最佳答案

对于C状态(已复制),您需要添加--find-copies-harder

 git log --find-copies-harder --name-status -3

如果您在新提交中添加文件的完整未修改副本,您将看到:

C100    b.bat   b1.bat

如果文件较大,-C -M 足以检测到副本。


对于 (T),一个简单的 chmod 755chmod 644 文件就足够了。
或者用文件替换符号链接(symbolic link)。
或者 gitlink (父存储库的 special entry recorded in the index,模式 16000)通过文件。

--diff-filter 很早就在 Git 中引入:commit f2ce9fd, Git v0.99, Jun 2005

你可以看到 diff.h .它用于 diff.c#diff_resolve_rename_copy()

所以如果你复制一个文件,不同的类型,它是(T)
DIFF_PAIR_TYPE_CHANGED定义为:

#define DIFF_PAIR_TYPE_CHANGED(p) \
((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))

( S_IFMT 0xF000 /* File type mask */ ,用于“How to read the mode field of git-ls-tree's output ”)

DIFF_PAIR_TYPE_CHANGEDGit v0.99 May 2005 中引入,很早以前。并在 Git v1.4.0-rc1, Apr. 2006 中重构.

关于git - 强制 git status 确认副本和类型更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38530510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com