How can I find out who force pushed in git?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
A force push rewrites branch history, which means the team usually wants two answers immediately: what changed, and who did it. Local Git can help reconstruct the history movement, but reliable attribution usually comes from the hosting platform’s audit trail rather than from your clone alone.
What Local Git Can Tell You
Your local repository can often show that the remote branch tip changed and what commits were added or removed. If your clone has a reflog for the remote-tracking branch, start there.
If you can identify the old and new tip SHAs, compare them directly:
This is good for reconstructing the branch change, but it does not prove who pushed it. Reflog entries are local observations, not authoritative audit records.
Use Server-Side Audit Logs for Attribution
If the repository is hosted on GitHub, GitLab, Bitbucket, or another managed platform, the most reliable attribution source is usually the server’s activity or audit logs.
A practical investigation flow is:
- identify the branch that moved
- narrow the time window from CI failures or team reports
- look for a non-fast-forward push event
- record the actor, old SHA, new SHA, and timestamp
That is the evidence you want when the question is specifically “who force pushed.”
Do Not Confuse Commit Author With Force-Push Actor
This is one of the most common mistakes in Git incident response. The author shown on commits is not necessarily the person who force pushed the branch. One developer may have authored the commits while another developer rewrote the branch history and pushed it.
That is why commit metadata is useful for reconstructing the history, but not for proving the account that initiated the force push.
Recover Lost History Carefully
Once you know what changed, the next step is often recovery. If the previous branch tip is known, you can restore it with a force push of your own. Use --force-with-lease instead of plain --force so you do not overwrite additional changes unexpectedly.
If the old SHA is not known, ask teammates to inspect their local reflogs. Any clone that fetched the branch before the rewrite may still know the earlier tip.
That can be enough to recover the lost commits even if the branch itself has already moved on.
Add Logging for Self-Hosted Git
If you run your own Git server, you can improve future investigations by logging non-fast-forward pushes in a server hook.
This does not just help with incident response. It also gives you a basis for alerts or policy enforcement on protected branches.
Prevent the Problem on Critical Branches
Attribution is useful after the fact, but prevention matters more. For important branches, consider:
- disabling force pushes entirely
- requiring pull requests and review
- requiring passing CI before merge
- limiting admin bypass to a small group
If a branch must allow force pushes, document when it is allowed and how the team should announce it. That makes later investigation much less chaotic.
Use an Incident Checklist
When a force push is suspected, a short checklist helps:
- pause further pushes to the affected branch
- capture the old and new SHAs
- check audit logs for the actor
- decide whether to restore history or keep the rewrite
- communicate the outcome to everyone working on the branch
This prevents a second accidental rewrite while you are still trying to understand the first one.
Common Pitfalls
The most common mistake is assuming the commit author and the force-push actor are the same person. Another is relying on a single developer’s reflog as the full source of truth. Teams also make recovery worse by using plain --force instead of --force-with-lease while investigating.
Summary
- Local Git can show what changed, but hosting-platform logs usually show who force pushed.
- Reflogs are useful for reconstruction and recovery, not for strong attribution by themselves.
- Capture old and new branch tips as early as possible during the investigation.
- Recover history with
--force-with-leasewhen restoration is required. - Strong branch protection reduces the need for this kind of investigation in the first place.

