Lex Humanitas reveals where form hides power and replaces meaning.

Instructions if “Git Broke” After a Rebase

A short procedure for typical errors:

  • ! [rejected] main -> main (non-fast-forward)
  • some local refs could not be updated

1) Create a Backup

git status
git branch --show-current
git branch backup/local-main-before-fix
git tag backup-before-fix-$(date +%Y%m%d-%H%M%S)

2) Repair Local Remote Refs

git remote prune origin
git fetch --all --prune
git branch -r | grep codex

If the refs error persists:

rm -rf .git/refs/remotes/origin
git fetch origin --prune

3) Choose a Strategy for main

git fetch origin
git rebase origin/main
git push

If the push is rejected again, repeat:

git fetch origin
git rebase origin/main
git push

Option B: Deliberately Overwrite Remote main

Use this only if you fully understand the consequences:

git fetch origin
git checkout main
git push --force-with-lease origin main

4) Quickly Check That Everything Is Synchronized

git status
git branch -vv
git log -1 --decorate --oneline
git push

Expected: Everything up-to-date.

Scroll to Top