You pushed commits to a remote and need to undo them. How bad this is depends on what you pushed and whether anyone else has pulled.
If you just pushed and need to revert the most recent commit:
git revert HEAD git push origin <branch> git revert creates a new commit that is the exact inverse of the target. Your history stays intact — nothing is deleted or rewritten.
Reverting is not enough. The secret is in your git history and anyone with repo access can find it. You need to rotate the credentials immediately and scrub the history.
bfg --delete-files .env git filter-branch --force --index-filter ... git push --force Force pushing rewrites public history. Coordinate with your team first. Anyone who already pulled will need to re-clone or reset.
Find the commit hash, revert it, then test before pushing. Others may have built on top of it.
git log --oneline git revert <commit hash> Rerun your tests before pushing. It's possible others wrote code depending on what you're reverting.
The remote history was rewritten. Your teammate's commits may still exist in their local reflog. Coordinate immediately.
git reflog # on the affected teammate's machine git reset --hard <lost-commit-hash> git push --force-with-lease