Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display metadata about single commit in git?

Tags:

git

I'd like to parse meta information from git repository. I'd like to fetch a single information for a commit, as in

git log --pretty=format:%an HEAD^..HEAD 

Problem is, this is not working for the first commit in repository.

git show --pretty=format:%an HEAD^..HEAD 

is also close to what I want, except I'm not interested in parsing actual diff.

Any idea how to make git log work for the first commit or how to disable git show from showing commit content?

Or, is there any better way how to retrieve metadata about given commit?

like image 601
Almad Avatar asked Dec 01 '09 19:12

Almad


People also ask

How do you see the details of a commit?

Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.

Where is the metadata stored in git?

The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.


2 Answers

Supply the quiet option to show to suppress the diff.

git show --quiet HEAD 

So for your example, author name:

git show --quiet --pretty=format:%an 
like image 69
CB Bailey Avatar answered Sep 22 '22 04:09

CB Bailey


git --no-pager show -s --format='%an <%ae>' COMMIT 
  • --no-pager supresses the pager
  • -s suppresses diff output; short for --no-patch
  • %an is the author name
  • %ae is the author email

(Taken from quora.com)

like image 21
koppor Avatar answered Sep 22 '22 04:09

koppor