Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get (only) author name or email in git given SHA1?

I would like to check for author's e-mail and name, surname to verify who's pushing to my repo.

Is there any way that I can come up with a command in git to show commiter's name/e-mail given only SHA1 of the commit?

This is what I came up with but it's far from ideal solution (the first solution is for git hook that's why it's using 2 SHA1s with rev-list. The second one simply uses git show):

git rev-list -n 1 --pretty=short  ccd3970..6ddf170 | grep Author | cut -d ' ' -f2- | rev | cut -d ' ' -f2- | rev git show 6ddf170 | grep Author | cut -d ' ' -f2- | rev | cut -d ' ' -f2- | rev  
like image 256
Patryk Avatar asked Apr 26 '15 10:04

Patryk


People also ask

How do you see commits by author?

2 Answers. Show activity on this post. git log --author=<pattern> will show the commit log filtered for a particular author. ( --committer can be used for committer if the distinction is necessary).

What is git author name?

Git store the name and the email of two persons for each commit: the committer and the author. The difference between the two is that the author is the person who wrote the changes, while the committer is the person who uploaded them the repository.

What is the difference between author and committer in git?

The author is the person who originally wrote the work, whereas the committer is the person who last applied the work. the author and the core member as the committer.


1 Answers

You can use the following command:

 git log --format='%ae' HASH^! 

It works with git show as well. You need to include -s to suppress the diff.

git show -s --format='%ae' HASH 
like image 198
Igal S. Avatar answered Sep 27 '22 21:09

Igal S.