当我运行 git log
并在寻呼机中查看时,我在提交旁边得到了一些不错的 ref 元数据:
commit 212b18778130cdf36effe441890826b76b97a09f (HEAD -> master, tag: TAG_8.0.2, origin/author/bootstrap_gcm, origin/master, origin/HEAD)
Merge: 4d7e0962f 7f687a431
Author: Joe, Smith <joe.smith@company.com>
Date: Sun Oct 4 18:03:37 2020 -0400
Merge branch 'jsmith/8.0.0_changes' into 'master'
See merge request project/project!1286
commit 4d7e0962fadc17ac3af23a85b64ecaf65d68bc42 (tag: TAG_8.0.1)
Merge: e7ccb690f cd10de563
Author: Joe, Smith <joe.smith@company.com>
Date: Fri Oct 2 19:54:31 2020 -0400
Merge branch 'project2' into 'master'
See merge request project/project!1285
我说的 ref 元数据是:
(HEAD -> master, tag: TAG_8.0.2, origin/author/feature_br1, origin/master, origin/HEAD)
(tag: TAG_8.0.1)
-- 在括号中提交的右侧。
但是,如果我执行 git --no-pager log > git.log
,所有引用信息都会丢失:
commit 212b18778130cdf36effe441890826b76b97a09f
Merge: 4d7e0962f 7f687a431
Author: Joe, Smith <joe.smith@company.com>
Date: Sun Oct 4 18:03:37 2020 -0400
Merge branch 'jsmith/8.0.0_changes' into 'master'
See merge request project/project!1286
commit 4d7e0962fadc17ac3af23a85b64ecaf65d68bc42
Merge: e7ccb690f cd10de563
Author: Joe, Smith <joe.smith@company.com>
Date: Fri Oct 2 19:54:31 2020 -0400
Merge branch 'project2' into 'master'
See merge request project/project!1285
两个问题。
为什么?发送到寻呼机的相同文本不应该也被重定向到文件吗?
有什么方法可以在转储到文件时将引用信息保留在括号中?
最佳答案
Shouldn't the same text sent to the pager also be redirected to a file?
否:decorate
的默认设置是decorate=auto
,auto 表示:
- 打开(设置为
short
)当转到屏幕(可能通过寻呼机)时,但是 - 转到文件时关闭(设置为
no
)。
这正是原因:
git --no-pager log --decorate > git.log
工作原理:--decorate
是将 decorate
设置设置为 short
的缩写,用于执行这一命令。
请注意,使用 git config
,您可以为 decorate
选项配置您自己的个人默认设置。参见 the git config
documentation ;搜索 log.decorate
。
关于Git 日志打印 Ref 元数据到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64211072/