用于在git中获取最后一个提交作者姓名的脚本

Sau*_*hal 0 git

如何获取作者对git repo的最新提交的名称?

#!/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
Run Code Online (Sandbox Code Playgroud)

Joh*_*pit 46

这就是你要找的东西:

git log -1 --pretty=format:'%an'
Run Code Online (Sandbox Code Playgroud)

  • 如果您需要将其用于脚本或变量,只需添加 `xargs`,例如。`git log -1 --pretty=format:'%an' | xargs` (4认同)

小智 22

或者检索作者的电子邮件,而不是姓名:

git log -1 --pretty=format:'%ae'
Run Code Online (Sandbox Code Playgroud)


smm*_*rab 8

获取作者姓名

git log -1 --pretty=format:'%an'
Run Code Online (Sandbox Code Playgroud)

要获取作者电子邮件

git log -1 --pretty=format:'%ae'
Run Code Online (Sandbox Code Playgroud)