如何跟踪GIT推力?您可以丢失/删除提交吗?

时间:2019-04-08 10:15:43

标签: git merge git-merge rebase

这是我们团队合作的仓库: https://github.com/hmcts/prd-pui-manager/pulls?q=is%3Apr+is%3Aclosed

对于为什么当我们拉下master时,在提交日志中看不到PR 45、46的问题,我们还是怀念不清。 https://github.com/hmcts/prd-pui-manager/pull/45 https://github.com/hmcts/prd-pui-manager/pull/46

我已经跑步:git reflog,看是否有强行推动,但什么也没显示。

具有PR 48:https://github.com/hmcts/prd-pui-manager/pull/48 删除了PR 45,46,如果是,怎么办?

有没有办法调试强制推送到主站?

我希望我能在这方面有所帮助,因为蜜蜂需要一段时间来了解如何调试这些流程。 我已经按照以下步骤尝试进行调试:

  • 恢复到每个标题并查看代码-什么都没有

合并PR 48时,它对PR 45也进行了更改,以返回丢失的代码,但是我想弄清楚我们是如何丢失两个PR的。

2 个答案:

答案 0 :(得分:1)

GitHub audit trail

GitHub has an audit log for troubleshooting such problems:

Documentation: https://developer.github.com/v3/activity/events/

In your case, analyzing https://api.github.com/users/hmcts/events might reveal what you are looking for. I browsed a bit for PushEvent on refs/heads/master, and for PullRequestEvents. I did not find your specific answer but with some digging you might be able to figure it out.

Losing commits

To answer the other part of your question, a forced push is the only way I know to lose commits.

答案 1 :(得分:0)

To fix the problem for now, you still have the branches, so you can merge them in master to get your changes.

For the future, I would suggest to enforce the following:

  • NEVER push force master or any other shared branch,
  • only branches belonging to single developers can be forced pushed, only if the developer knows what he/she does

Also, in the case you don't have the branches anymore, you can look across the developers's computers, compare the logs and reflogs and reconstruct your branch from the different places (for example, dev 1 will have the old version in his reflog, so you can pull the current master, and merge this old version, which has been deleted, dev 2 will have the forced pushed version, and so on). It is a tedious task, but that's the best way to recover lost data.