git - git status -s 的彩色全行

标签 git

命令 git status -s 将输出短格式的 git status。每个文件的状态将被着色,例如M 将是红色或绿色;然而,与普通的 git status 不同的是,文件不会被着色。它们显示为您终端的默认颜色。

有没有办法在仍然使用短格式输出的同时将文件着色为与其状态相同的颜色?

最佳答案

这对于原生 git 来说是不可能的,因为 t/t7508-status.sh测试脚本说明:

test_expect_success 'status with color.status' '
    test_config color.status always &&
    git status | test_decode_color >output &&
    test_i18ncmp expect output
'

cat >expect <<\EOF
 <RED>M<RESET> dir1/modified
<GREEN>A<RESET>  dir2/added
<BLUE>??<RESET> dir1/untracked
<BLUE>??<RESET> dir2/modified
<BLUE>??<RESET> dir2/untracked
<BLUE>??<RESET> untracked
EOF

如您所见,颜色在短状态指示器之后和文件名之前重置。


注意:目前唯一的改进(Git 2.13.x/2.14,2017 年第 3 季度)是关于分支颜色。

参见 commit 75177c8 (2017 年 4 月 27 日)Jeff King (peff) .
参见 commit 93fdf30 (2017 年 4 月 22 日)Stephen Kent (stevejameskent) .
(由 Junio C Hamano -- gitster -- merge 于 commit 3900254 ,2017 年 5 月 16 日)

status: add color config slots for branch info in "--short --branch"

Add color config slots to be used in the status short-format when displaying local and remote tracking branch information.

关于git - git status -s 的彩色全行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29423742/

相关文章:

java - 模块化 Maven 项目和多个 Git 存储库

php - 如何在 Windows 8 的 xmpp 中安装 zend

Gitignore 错误地排除了子文件

git clean filter 显示 git diff 结果的差异

git - git merge another-branch 和 git pull remote another-branch 的区别

混帐克隆 : GnuTLS recv error (-9): A TLS packet with unexpected length was received

git - 列出已通过 rebase merge 的分支

git - 连接到 TFS 服务器关闭 Git 解决方案

git - 是否有针对开发人员的 SCM 公认的 "best"或规范书籍?

git - TFS 2010 多个解决方案和带有门控 checkin 的构建