简体   繁体   English

在 FF 合并之前查找最后一次提交

[英]Find last commit just before a FF merge

Is it possible to find the previous branch tip after a FF merge? FF合并后是否可以找到上一个分支提示? In my case the new branch tip is a merge commit and there is a whole topology added from this FF merge but do not think that matters.在我的情况下,新的分支提示是一个合并提交,并且从这个 FF 合并中添加了一个完整的拓扑,但不认为这很重要。 My issue is to find out the commit before applying the merge.我的问题是在应用合并之前找出提交。

It's not findable from the commit graph .提交图中找不到它。

If Git still retains the previous commit hash in the relevant reflogs , it is findable from the reflogs.如果 Git 在相关的 reflogs 中仍然保留之前的 commit hash ,则可以从 reflogs 中找到。

Reflogs are specific to one particular clone , so if the fast-forward happened in some other clone, you cannot use this method to find the previous hash ID. Reflogs 特定于一个特定的克隆,因此如果快进发生在其他克隆中,则无法使用此方法查找以前的 hash ID。 If the fast-forward happened in your clone, you can.如果快进发生在您的克隆中,您可以。 Use git reflog branch-name to view the reflog, which will show stuff like this:使用git reflog branch-name查看 reflog,它将显示如下内容:

$ git reflog master
b994622632 (HEAD -> master, origin/master, origin/HEAD) master@{0}: merge refs/remotes/origin/master: Fast-forward
b34789c0b0 master@{1}: merge refs/remotes/origin/master: Fast-forward
d61d20c9b4 master@{2}: merge refs/remotes/origin/master: Fast-forward
...

Each of those hash IDs is one of the hash IDs that refs/heads/master held in the past, or (for master@{0} ) holds now.每个 hash ID 都是过去持有的refs/heads/master或(对于master@{0} )现在持有的 hash ID 之一。 So usually name @{1} is the one you would want here.所以通常name @{1}是您想要的名称。

Depending on the git host you're using and the way you work, your host may have recorded the pushes.根据您使用的 git 主机和您的工作方式,您的主机可能已经记录了推送。 If your target branch was up to date with your remote, you merge ant then you push, then the push history will show you a nice picture:如果你的目标分支与你的遥控器是最新的,你合并 ant 然后你推送,那么推送历史将向你展示一张漂亮的图片:

Example from Azure Devops:来自 Azure Devops 的示例:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM