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

有没有办法用git日志显示远程引用?,git,gerrit,git-log,Git,Gerrit,Git Log,上面的命令给出了以下结果: git log --oneline 但因为我用的是gerrit,而且通常gerrit的变更号是refs/changes/。。。格式,我想收集如下框架的列表: 5485b34 Modify: something ccaf2c4 Modify: another thing 85a87e8 Bug Fix: the other thing 我知道有一种方法可以通过使用“gitlsremote”获得提交id和远程引用之间的映射。通过使用“gitlsremote”,我可以

上面的命令给出了以下结果:

git log --oneline
但因为我用的是gerrit,而且通常gerrit的变更号是refs/changes/。。。格式,我想收集如下框架的列表:

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

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

通过使用git log--oneline--pretty=format:“You\u format\u here”,您可能会得到您想要的东西。


查看手册页中的所有可用选项:

我认为不可能以您想要的方式获取信息,但您可以通过以下操作获取大量Gerrit review信息:

1) 配置存储库以获取审阅信息

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
2) 之后,每次更新都会带来评论信息

$ git config --add remote.origin.fetch refs/notes/review:refs/notes/review
3) 要查看审阅信息,请将“-notes=review”添加到“git log”命令中


您可以使用
--decoration
选项在日志中显示引用。
但它只会显示本地引用和获取的引用,因此不会显示
refs/changes/x/yyyy/zz
,您必须先获取它们:

$ 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
然后您将得到如下输出:

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

非常感谢你。这是我真正想要的。
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