// Git Emergency

What did you break?

Pick your disaster. We explain what happened, how bad it is, and how to get out of it — safest option first.

fatal: Git printed an error? Find its meaning and the fix in our list of error messages.

Commits & local work

Branches, merges & rebases

Push & remote

I pushed directly to main

Serious

No PR, no review, straight to main. Undo it without rewriting shared history.

I forgot to pull before pushing

Minor

Push rejected, an ugly “Merge branch 'main' of…” commit, or hours of work on an outdated version.

My push is rejected (non-fast-forward)

Minor

“Updates were rejected because the remote contains work that you do not have locally.”

I amended a commit that was already pushed

Annoying

Now git push is rejected and Git says your branch has diverged.

I pushed to the wrong branch

Annoying

Your commits landed on a colleague's branch, or on a branch with a typo in its name.

I overwrote a colleague's commits

Critical

A git push --force wiped someone else's work from the remote.

GitHub rejects a file over 100 MB

Annoying

“remote: error: File is 245 MB; this exceeds GitHub's file size limit.”

I pulled and my code disappeared

Serious

Almost always recoverable: Git refuses to overwrite uncommitted work, and the reflog remembers the rest.

I deleted a branch on GitHub / GitLab

Annoying

If anyone still has it locally, push it back. GitHub also offers a “Restore branch” button on the pull request.

I pushed with the wrong GitHub account

Minor

Two accounts (personal / work) on one machine: separate them per folder or per SSH key.

The repository was renamed or moved

Minor

Point your remote to the new address. Nothing else changes.

I tagged the wrong commit

Annoying

Move the tag locally; if it was pushed (and maybe released), think twice before moving it.

Pull requests

Files & repository

Security

Golden rule: before any destructive command, create a safety branch with git branch backup/before-fix — it costs nothing.