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
- Fetch the remote branch, examine the divergence, and reconcile (merge/rebase) before pushing.
- If force pushing is genuinely required, remove or set git.disableForcePushing: false in the lazygit config, then retry and confirm.
- 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
- Keep git.disableForcePushing: true for shared branches and always fetch-and-rebase on rejection.
- Surface the config setting in the error UX so users know why force push was not offered.
- Use dedicated throwaway branches when history rewrites are expected.
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
- Your branch has diverged from the remote branch and you've d
- Must specify a remote if specifying a branch
- Updates were rejected. Please fetch and examine the remote c
- git.diffRenderers: unknown type '%s'. Allowed values: stdinF
- Git version must be at least %s. Please upgrade your git ver
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/b201f7a356226115.
Report an issue: GitHub.