【问题标题】:How can I show the name of branches on every commit in `git log`如何在`git log`中的每次提交上显示分支名称
【发布时间】:2012-05-22 12:31:16
【问题描述】:

在 Gitk 中,显示提交会给出如下输出:

Author: ...
Committer: ...
Parent: ...auth/parser)
Parent: ... (Merge branch '...')
Child:  ...
Branches: remotes/me/foo, foo

有没有办法在git log 中获得这种输出?使用git log --graph 提供了类似的信息,但在我的具有长期存在的分支的存储库中,可能需要大量滚动才能找到提交所在的分支。

(与How can I show the name of branches in `git log`?类似的问题)

【问题讨论】:

    标签: git git-branch git-log


    【解决方案1】:

    我用这个:

    git log --pretty=format:\"%h %ad [%an] %s%d\" --graph --date=short
    --all --date-order
    

    我为我的全局 .gitconfig 添加了别名

    [alias]
        hist = log --pretty=format:\"%h %ad [%an] %s%d\" --graph --date=short --all --date-order
    

    并且可以调用简单的git hist

    它制作了非常易于阅读的修订树,其中包含简短的提交哈希、作者、日期、分支、HEAD 等在一行上

    【讨论】:

    • 我使用类似的东西,但“%d”只给标签每个分支的尖端。我希望有一些东西可以标记每个提交。
    • 我用的那个:git log --pretty='%Cblue%h%C(cyan)%d%Cred %cn %Cgreen %ar %Creset %s'
    • @radisto,我试过你的命令。它给出了一个错误:致命:不明确的参数'%ad':未知的修订或路径不在工作树中。使用 '--' 将路径与修订分开,如下所示:'git [...] -- [...]'。我正在使用 git 版本 1.9.3
    • 看起来您使用了一些额外的日志格式,这与“%ad”有歧义。见superuser.com/questions/273570/…
    • 它不显示所有提交的分支,只显示最后一个。
    猜你喜欢
    • 2010-12-22
    • 2012-12-06
    • 1970-01-01
    • 1970-01-01
    • 2021-09-22
    • 1970-01-01
    • 1970-01-01
    • 2022-12-03
    • 1970-01-01
    相关资源
    最近更新 更多