我正在创建一个 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
Run Code Online (Sandbox Code Playgroud)
在其他机器上,使用相同的步骤创建存储库后,我可以看到 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
Run Code Online (Sandbox Code Playgroud)
如果我遗漏了什么,请告诉我。谢谢
您此处可能有不同的配置条目。看log.decorate
但无论如何,要在日志输出中的提交哈希之后明确提及分支/标签信息,请使用标志
# to force it
git log --decorate
# to prevent it
git log --no-decorate
Run Code Online (Sandbox Code Playgroud)
正如托雷克在下面的评论中指出的那样,阈值是更精确的1.7.2版本,log.decorate完全出现在其中。在那之前,根本没有任何装饰,从那时起它就默认为auto(意味着它默认打开)。