首页 > 解决方案 > 我怎样才能得到最后一个在遥控器上提交的人的名字?

问题描述

我知道-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会是什么。

标签: bashgit

解决方案


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

--quiet- 抑制差异输出

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

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

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


推荐阅读