代码之家  ›  专栏  ›  技术社区  ›  김창중

有没有办法用git日志显示远程引用?

  •  1
  • 김창중  · 技术社区  · 7 年前
    git log --oneline
    

    5485b34 Modify: something 
    ccaf2c4 Modify: another thing
    85a87e8 Bug Fix: the other thing
    

    refs/changes/85/104085/9 Modify: something
    refs/changes/33/104033/9 Modify: another thing
    refs/changes/83/104183/2 Bug Fix: the other thing
    

    我知道有一种方法可以通过使用“git ls remote”获得提交ID和远程引用之间的映射。通过使用“git ls remote”,我可以制作一个脚本来获得上述结果。但是,有没有更好更简单的方法来获得上述结果?

    3 回复  |  直到 7 年前
        1
  •  2
  •   zigarn    7 年前

    --decorate 选项
    但它将只显示本地和获取的引用,因此 refs/changes/x/yyyy/zz

    git config --add remote.origin.fetch refs/changes/*:refs/remotes/gerrit/changes/*
    

    # You can add '--all' to see other references not in the current history
    $ git log --oneline --decorate
    5485b34 (HEAD -> master, origin/master, origin/HEAD, gerrit/changes/85/104085/9) Modify: something 
    ccaf2c4 (gerrit/changes/33/104033/9) Modify: another thing
    85a87e8 (gerrit/changes/83/104183/2) Bug Fix: the other thing
    
        2
  •  0
  •   Marcelo Ávila de Oliveira    7 年前

    1) 配置存储库以获取评论信息

    $ git config --add remote.origin.fetch refs/notes/review:refs/notes/review
    

    $ git fetch
    
    remote: Counting objects: 66, done
    remote: Finding sources: 100% (66/66)
    remote: Total 66 (delta 18), reused 66 (delta 18)
    Unpacking objects: 100% (66/66), done.
    From https://GERRIT-SERVER/REPO-FULLNAME
    * [new ref] refs/notes/review -> refs/notes/review
    

    3) 要查看查看信息,请将“-notes=review”添加到“git log”命令中

    $ git log --notes=review
    
    commit a5bc87cb44e5e68154fb8bd3559f9753e1540fd7
    Author: AUTHOR
    Date: Thu May 8 16:02:16 2017 -0300
    COMMIT-MESSAGE
    Change-Id: CHANGE-ID
    Notes (review):
    Verification+1: REVIEWER1
    Code-Review+1: REVIEWER2
    Code-Review+1: REVIEWER3
    Code-Review+2: REVIEWER4
    Submitted-by: SUBMITTER
    Submitted-at: Fri, 09 May 2017 08:23:28 -0300
    Reviewed-on: https://GERRIT-SERVER/CHANGE-NUMBER
    Project: REPO-FULLNAME
    Branch: refs/heads/BRANCH
    
        3
  •  -1
  •   YoannFleuryDev    7 年前

    你可以通过使用 git log --oneline --pretty=format:'you_format_here'

    查看手册页中的所有可用选项: https://git-scm.com/docs/pretty-formats