Read more

Git: Force a rejected push

Tobias Kraze
December 06, 2010Software engineer at makandra GmbH

If you modified git's history and the change was already pushed, you will usually get a
! [rejected] my-branch -> my-branch (non-fast-forward)
error, when trying to push.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

You can force the push, with
git push --force origin my-branch

Careful:

  • You might lose history.
  • Unless your git is configured to push only the current branch, you must supply the remote branch name or you will force-push all your branches!
  • Anyone else who has already pulled the changes will run into significant trouble.

Only do this to instantly fix a mistake, or when you know exactly what you're doing.

Posted by Tobias Kraze to makandra dev (2010-12-06 12:28)