You pushed. GitHub said no. The instinct to reach for force is strong. Don't. A rejected push usually means GitHub knows something your computer doesn't—and that's a cue to investigate, not to swing the biggest hammer you own.

What a rejected push means

A "non-fast-forward" rejection means the remote branch has commits your local branch doesn't. Your push would overwrite them. Git is protecting shared history. Let it.

Investigate first

Check the current branch:

git branch --show-current

See where you stand:

git status

Fetch the remote changes:

git fetch origin

Review what changed on the remote:

git log HEAD..origin/your-branch --oneline

Handle your local work

If you have intentional local work, commit it or stash it safely:

git stash

Don't throw away uncommitted changes to "make the push work."

Integrate, don't overwrite

Rebase or merge according to your team's workflow. Resolve conflicts carefully, one at a time—read the conflict, don't just pick "ours" or "theirs" by reflex. Run validation again (lint, tests, build) before pushing.

Push normally

Once your branch includes the remote changes, push normally:

git push origin your-branch

No flags.

Why force-push is dangerous

Force-push rewrites history. It can erase commits other people built on. It can make teammates' local branches incompatible. In shared branches, it's the kind of thing that ends with someone rebuilding a day's work.

The rare, coordinated exception

In advanced workflows, a protected, coordinated force-push can exist—on a personal feature branch no one else uses, with the team's knowledge. That's not the normal fix, and it's never the first response to a rejected push.

Optional workstation safeguard

If you've force-pushed by accident before and want a guardrail, you can disable pushes from a specific local remote:

git remote set-url --push origin DISABLED

This makes that local remote unable to push. It's a personal tripwire, not a security control. It does not replace GitHub permissions, pull-request review, or branch protection. It just stops your muscle memory from doing something regrettable on this machine.

Takeaway

A rejected push is information. Read it, integrate, and push normally. The hammer is for emergencies, not Tuesdays.