jesseduffield/lazygit · error

Updates rejected and you have disabled force pushing

Error message

Updates rejected and you have disabled force pushing

What it means

Returned by SyncController.pushAux in the same 'Updates were rejected' path as error 91, but when the remote branch is NOT stored locally and UserConfig().Git.DisableForcePushing is true. lazygit would normally offer a force-push confirmation here, but the config option forbids it, so the rejection is surfaced with an explanation that force pushing is disabled.

Source

Thrown at pkg/gui/controllers/sync_controller.go:216

		err := self.c.Git().Sync.Push(
			task,
			git_commands.PushOpts{
				Force:          opts.force,
				ForceWithLease: opts.forceWithLease,
				CurrentBranch:  currentBranch.Name,
				UpstreamRemote: opts.upstreamRemote,
				UpstreamBranch: opts.upstreamBranch,
				SetUpstream:    opts.setUpstream,
			})
		if err != nil {
			if !opts.force && !opts.forceWithLease && strings.Contains(err.Error(), "Updates were rejected") {
				if opts.remoteBranchStoredLocally {
					return errors.New(self.c.Tr.UpdatesRejected)
				}

				forcePushDisabled := self.c.UserConfig().Git.DisableForcePushing
				if forcePushDisabled {
					return errors.New(self.c.Tr.UpdatesRejectedAndForcePushDisabled)
				}
				self.c.Confirm(types.ConfirmOpts{
					Title:  self.c.Tr.ForcePush,
					Prompt: self.forcePushPrompt(),
					HandleConfirm: func() error {
						newOpts := opts
						newOpts.force = true

						return self.pushAux(currentBranch, newOpts)
					},
				})
				return nil
			}
			return err
		}
		self.c.RefreshFromWorker(types.RefreshOptions{})
		return nil
	})

View on GitHub (pinned to c477a2959b)

Solutions

  1. Fetch the remote branch, examine the divergence, and reconcile (merge/rebase) before pushing.
  2. If force pushing is genuinely required, remove or set git.disableForcePushing: false in the lazygit config, then retry and confirm.
  3. Push to a different branch name if overwriting the remote is unacceptable.

Example fix

# before
# ~/.config/lazygit/config.yml
git:
  disableForcePushing: true

# after
git:
  disableForcePushing: false
Defensive patterns

Strategy: fallback

Validate before calling

if self.c.UserConfig().Git.DisableForcePushing {
    // reconcile with remote (fetch + rebase/merge) instead of pushing over it
}

Prevention

When it happens

Trigger: A non-force push rejected with 'Updates were rejected', remoteBranchStoredLocally == false, and git.disableForcePushing: true in the user config.

Common situations: Users who deliberately set disableForcePushing to protect shared branches; pushing a brand-new local view of a remote branch after history was rewritten elsewhere.

Related errors


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/b201f7a356226115. Report an issue: GitHub.