在 git 中获取最后提交作者姓名的脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41548698/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:32:46 来源:igfitidea点击:
Script to get last commit author name in git
提问by Saurabh singhal
How to get the author's name of the latest commit to a git repo?
如何获取 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
回答by John Bupit
This is what you're looking for:
这就是你要找的:
git log -1 --pretty=format:'%an'
回答by Donald Steffy
Or to retrieve the author's email, instead of name:
或者检索作者的电子邮件,而不是姓名:
git log -1 --pretty=format:'%ae'