Force Push Confirm

Lists every commit a force push would drop, marks other people's work and builds a safer lease command, so teammates' commits aren't erased.

StopsTeammates' commits erased by force push

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/force-push-confirm.json

The files land in your project. They're yours to edit.

Usage

force-push-confirm-usage.tsx
import { ForcePushConfirm, type RemoteCommit } from "@/components/ui/force-push-confirm"

<ForcePushConfirm
  branch="feature/checkout"
  remoteSha={tip}
  lost={commits(base)}
  me={{ emails: ["tushar@users.noreply.github.com"] }}
  protectedBranches={["main", "release/*"]}
  otherBranches={["main", "develop"]}
  onCancel={() => setDone("Cancelled. Nothing was pushed.")}
  onConfirm={({ command }) => new Promise<void>((resolve) => setTimeout(() => (setDone(`Ran: ${command}`), resolve()), 700))}
/>

What it catches

  • Commits on the remote that the push would drop
  • Commits by other people, including co-authors and GitHub noreply addresses
  • Protected branches
  • A remote tip that moved since you looked
  • Plain --force, replaced by a pinned --force-with-lease

Props

ForcePushConfirm props
PropTypeDefault
otherBranches

Other branch names; typing one of them is called out instead of silently not matching.

string[][]
defaultLease

Start with the lease on.

booleantrue
onConfirm

Called with the command to run. May return a Promise; the button shows a pending state and ignores repeat clicks.

(push: { command: string; lease: boolean }) => void | Promise<void>—
onCancel

Shows a Cancel button.

() => void—
maxCommits

How many lost commits to list before a "Show more" button; other people's commits are always listed first.

number8
locale

Locale for "3 hours ago" and the people list.

string—
messages

Any visible string.

Partial<ForcePushMessages>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Dropped commits are a labelled list
  • The lease option is a labelled checkbox; branch confirmation is a typed field
  • Warnings use icons plus text

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Protect shared branches in your Git host (no force pushes, required reviews); this dialog only prepares a safer command.

  • Uses the commit lists you pass; it doesn't run git
  • --force-with-lease only protects the tip you pinned; your Git host's branch protection is the real guard

What it stops

Teammates' commits erased by force push

Also known as

git push --force · force-with-lease · force-if-includes · rebase · protected branch · github · remote branch

Field type

Dependencies

Pairs well with