首页 > 解决方案 > Git #hashtags 状态

问题描述

我在两台机器之间移动,现在我所有的git status命令输出都充满了#

我有相同的.gitconfig.bashrc文件。

还测试了制作一个新的 git clone,同样的情况。

在我的旧电脑上看起来很正常:

On branch xxx
Your branch is up to date with 'origin/xxx'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   xxx

在我的新电脑上,它充满了“评论”:

# On branch xxx
# Your branch is up to date with 'origin/xxx'.
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   xxx

如何删除这些标签?

标签: linuxgit

解决方案


默认情况下,较旧的 git 版本仅打印在行#的前面。git status它在较新的版本中被删除。

请参阅https://github.com/git/git/commit/2556b9962e7c0353d562b7bf70eed11d8f29d0b0#diff-21ecaaf4e2318a39cdedf505941dbfbabd3329f041c839a03fb84906b4dae4fb此提交。

status: 默认不显示'#'注释前缀

从历史上看,“git status”需要在每个输出行前加上“#”,以便可以将输出作为注释添加到提交消息中。当从命令行运行“git status”时,此前缀注释没有实际用途,这可能会分散用户对真实内容的注意力。

默认禁用此前缀注释,并使其对需要向后兼容 status.displayCommentPrefix 的用户重新激活。

显然,“git commit”在写入 COMMIT_EDITMSG 时会忽略 status.displayCommentPrefix 并无条件地保留注释(但在写入 stdout 以获取错误消息或使用 --dry-run 时不会)。

签字人:Matthieu Moy Matthieu.Moy@imag.fr 签字人:Junio C Hamano gitster@pobox.com


推荐阅读