Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the author of the last commit in Git?

Tags:

How to get the author of the latest commit in a Git repository?

#!/bin/bash  git_log=`git ls-remote git url  master` git_commitId = git_log | cut -d " " -f1 echo $git_commitId  cd /workspace git_log_verify = `git rev-parse HEAD` echo $git_log_verify  if $git_commitId =$git_log_verify then     cd /workspace     git_authorName=`git log --pretty=format:"%an"`;     echo $git_authorName fi 
like image 448
Saurabh singhal Avatar asked Jan 09 '17 13:01

Saurabh singhal


People also ask

How can I see last commit name?

Viewing a list of the latest commits. If you want to see what's happened recently in your project, you can use git log . This command will output a list of the latest commits in chronological order, with the latest commit first.

How do I get the last commit code?

To view the previous commits, use the git log –-oneline command. This provides the commit details.


2 Answers

This is what you're looking for:

git log -1 --pretty=format:'%an' 
like image 149
John Bupit Avatar answered Oct 18 '22 16:10

John Bupit


Or to retrieve the author's email, instead of name:

git log -1 --pretty=format:'%ae' 
like image 39
Donald Steffy Avatar answered Oct 18 '22 17:10

Donald Steffy