在我使用 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/