Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git log output to XML, JSON, or YAML?

This is a pretty simple question: as a Git newbie I was wondering if there's a way for me to output my git log to a file, preferably in some kind of serialized format like XML, JSON, or YAML. Any suggestions?

like image 433
Andrew Avatar asked Jan 05 '11 02:01

Andrew


People also ask

What is the output of git log?

By default, git log includes merge commits in its output. But, if your team has an always-merge policy (that is, you merge upstream changes into topic branches instead of rebasing the topic branch onto the upstream branch), you'll have a lot of extraneous merge commits in your project history.

What is the output of git log -- pretty Oneline?

Under --pretty=oneline , the commit message is prefixed with this information on the same line. This option cannot be combined with --reverse . See also git-reflog[1]. Under --pretty=reference , this information will not be shown at all.

What is git log file?

Git log is a utility tool to review and read a history of everything that happens to a repository. Multiple options can be used with a git log to make history more specific. Generally, the git log is a record of commits.

How does git log follow work?

With git log --follow , Git runs an after-diff step (called from diff_tree_sha1 ; see footnotes) that trims everything down to one file. The diff is done with R=C and L=P.


1 Answers

to output to a file:

git log > filename.log 

To specify a format, like you want everything on one line

git log --pretty=oneline >filename.log 

or you want it a format to be emailed via a program like sendmail

git log --pretty=email |email-sending-script.sh 

to generate JSON, YAML or XML it looks like you need to do something like:

git log --pretty=format:"%h%x09%an%x09%ad%x09%s" 

This gist (not mine) perfectly formats output in JSON: https://gist.github.com/1306223

See also:

  • http://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History
  • Git how to save a preset git log --format
  • How to parse the output of git log
like image 139
huntar Avatar answered Oct 06 '22 23:10

huntar