git - 如何在 merge 前找到最后一次 git 提交

标签 git

在我使用 git 从一个工作分支 merge 到我的 master 分支后,有时我想查找在 merge 发生之前在 master 上的最后一次提交。我该怎么做?

最佳答案

确定 merge 发生后提交的快速方法是使用 reflog .

假设最后发生的操作是 merge ,那么:

git log HEAD@{1} -1

HEAD@{1} 指的是最后一个操作之前的前一个 HEAD,因此您可以使用 log 和 reflog 来解决它。

git log将向您显示当前分支中的提交顺序,因此在 merge 之后它始终是 merge 提交,并且在它之前将是来自 merge 分支的提交。 git reflog显示存储库中的操作顺序(例如 merge 、 rebase )。如文档中所述:

Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository. Reflogs are useful in various Git commands, to specify the old value of a reference.

关于git - 如何在 merge 前找到最后一次 git 提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41628914/

相关文章:

git - 没有重命名检测的自定义 Git merge 驱动程序

ruby-on-rails - 部署重写的 Github/Heroku 应用程序

git - 如何git记录远程所有分支?

android - 错误: Unable to fully sync the tree while cloning AOSP

c# - 将分支名称获取到代码中

在 VS Code 中找不到 Git

git - 我怎样才能看到我最后一次 git pull 的时间?

merge MR 时 Gitlab CI 运行作业

linux - 静态 Git 构建中链接时 undefined reference

git + assembla + 多个 ssh key /多台计算机