Search code examples
gitmergegit-mergerebase

How to track GIT force pushes? Can you lose/delete commits?


Here is a repo we are working on as a team: https://github.com/hmcts/prd-pui-manager/pulls?q=is%3Apr+is%3Aclosed

We are having miss understanding in why when we pull down master, we don't see the PR 45, 46 in the commit logs. https://github.com/hmcts/prd-pui-manager/pull/45 https://github.com/hmcts/prd-pui-manager/pull/46

I have run: git reflog and looked if there is any force push, but does not show anything.

Has PR 48: https://github.com/hmcts/prd-pui-manager/pull/48 removed PR 45,46 , if yes how?

Is there a way to debug force push to master?

I hope I can get help with this as bee a struggle for a while to understand how to debug these flows. I have followed these steps to try to debug:

  • Revert to each head and review code - nothing

When PR 48 was merged it had PR 45 changes also to return back the code that has been lost, but I want to figure out how we lost two PR's


Solution

  • 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.