使git显示以机器可解析的格式显示信息 [英] Making git show to show information in a machine parseable format

查看:115
本文介绍了使git显示以机器可解析的格式显示信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读解析git日志输出,最好是xml 但这没有帮助。我正在尝试获取有关git标记的以下信息:


  1. 创建标记的用户

  2. 与标签创建相关的消息,如果有的话

  3. 标签的名称(我知道这是我已经通过这个),但我希望它们在输出中,以便我可以将整个输出给我的来电者

  4. 该标签上的最新提交ID

我更喜欢他们作为csv或空格/制表符分隔值,所以我试图使用--format选项。我正在尝试像

  git show my_label_name --pretty = format:%an,%cn--quiet 

但这不会产生我想要的。有人可以帮我吗?


将为您提供表示该标记的文件的实际内容(有助于解压缩和解压缩)。



示例



  $ git init 
$ touch README
$ git add自述文件
$ git commit -m'初始提交'
$ git标记-a foo -m'标记foo'
$ git cat-file标记foo
对象91654534f5ac138a3adb56a9e6dc3bacae5bae53
type commit
tag foo
tagger Peter Lundgren< peter@peterlundgren.com> 1369779403 -0400

标记foo


I have read parsing git log output, preferably as xml but that does not help. I am trying to get the following information about a git tag

  1. User that created the tag
  2. Message associated with tag creation if any
  3. The name of the tag (I know this as I already pass this) but I want them in the output so that I can just pass the whole output back to my caller
  4. The latest commit id on that tag

I would prefer them as csv or space/tab separted values so I was trying to use the --format option. I was trying things like

 git show my_label_name --pretty=format:"%an, %cn" --quiet

but this does not produce what I want. Can someone help me?

解决方案

git cat-file tag <tag_name>

will give you the actual contents of the file that represents that tag (helpfully unpacked and uncompressed).

Example

$ git init
$ touch README
$ git add README
$ git commit -m 'Initial commit'
$ git tag -a foo -m 'Tagging foo'
$ git cat-file tag foo
object 91654534f5ac138a3adb56a9e6dc3bacae5bae53
type commit
tag foo
tagger Peter Lundgren <peter@peterlundgren.com> 1369779403 -0400

Tagging foo

这篇关于使git显示以机器可解析的格式显示信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆