git 日志命令不显示 HEAD 信息

git log command doesnt show HEAD info

我正在创建一个 git 存储库并使用 git commit 向存储库添加一个文件。 在 git log 中提交后,我可以看到提交信息,但看不到 HEAD 信息。以下是我遵循的步骤:

$ git config --global user.name "abc"
$ git config --global user.mail "abc@abc.com"
$ git init
  Initialized empty Git repository in /home/aishwarya/github.com/temp/.git/
$ touch a.txt
$ git add a.txt

$ git commit --message "first commit in NonBareRepo"
  [master (root-commit) 6d46130] first commit in NonBareRepo
   1 file changed, 0 insertions(+), 0 deletions(-)
   create mode 100644 a.txt
$ git log
  commit 6d46130416eef0104408d575d8d4958457fe1dab
  Author: abc <abc@abc.com>
  Date:   Mon Feb 3 22:07:18 2020 +0530

      first commit in NonBareRepo

在其他机器上,以相同步骤创建存储库后,我可以看到 git 日志输出如下(HEAD 指向 master):

$ git log
commit 7ba4781ddee49a3636ee700fe057c3a372502460 (HEAD -> master)
Author: abc <abc@abc.com>
Date:   Mon Feb 3 22:01:11 2020 +0530

    first commit in NonBareRepo

如果我遗漏了什么,请告诉我。谢谢

您可能在此处有不同的配置条目。参见 log.decorate

但是无论如何,要明确地在日志输出中的提交散列之后提及branch/tag信息,请使用标志

# to force it
git log --decorate

# to prevent it
git log --no-decorate

正如 torek 在评论 中指出的那样,阈值更准确地说是 1.7.2 版本,其中 log.decorate 完全出现了。在那之前,根本没有装饰,从那以后它默认为auto(意味着它默认打开)。