我怎样才能得到最后一个在遥控器上提交的人的名字



我知道选项-force-with-lease允许我仅在上次提交时才按力,但我想允许覆盖它:

git push playground $current_branch:master --force-with-lease
if ! [[ "$?" == "0" ]]; then
    last_committer="$(git some command)"
    ask_continue "the last committer was $last_committer, would you like to push force?"
    git push playground $current_branch:master --force
fi

在这个例子中,我想知道git some command会是什么。

git show --quiet --pretty=format:%an

--quiet - 抑制差异输出

%an - 是作者姓名(对于所有其他格式,请单击此)

如果您想查看谁在特定分支
上进行了最后提交

git show --quiet --pretty=format:%an origin/branch-name

为了获得作者姓名的上次提交详细信息,日期和时间是

git log -1

在这里,您可以找到有关获取提交历史记录的更多详细信息。https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History

希望这对你有帮助。

最新更新