gpt4 book ai didi

Git 状态 : show mode (permission) changes

转载 作者:行者123 更新时间:2023-12-05 07:18:23 27 4
gpt4 key购买 nike

当我运行 git status 时,很多文件都被修改了:

$ git status
On branch feature-branch
Your branch is up to date with 'origin/feature-branch'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: file1.txt
modified: file2.txt
modified: file3.txt
...

有没有办法表明这些文件只是改变了它们的权限(模式),而不是内容?我想输出会是这样的:

$ git status
On branch feature-branch
Your branch is up to date with 'origin/feature-branch'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: file1.txt (100644 → 100755)
modified: file2.txt (100644 → 100755)
modified: file3.txt (100644 → 100755)
...

我知道 git diff 会显示如下内容:

diff --git file1.txt
old mode 100644
new mode 100755

但如果 git status 已经向我展示了这一点,我更愿意。


备注:This question看起来很相似,但在那种情况下,git status 根本没有检测到模式更改。在我的例子中,文件被标记为已修改,但我想区分普通文件编辑(修改内容)与仅更改权限。

最佳答案

我不相信 git 会那样做。 Git 为文件更改保留这些状态

  •   ' ' = unmodified
• M = modified
• A = added
• D = deleted
• R = renamed
• C = copied
• U = updated but unmerged

Git 足够聪明,可以告诉我们有关重命名的信息,但它仍然处于有关模式更改的状态。

但是你可以自己编写一个脚本来解析文件的差异并查看模式是否已更改,然后它会更改默认 git status 的输出。

关于Git 状态 : show mode (permission) changes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58320414/

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