{"record":{"id":"9da6ab1663eed68d","repo":"gitbutlerapp/gitbutler","slug":"cannot-push-branch-the-push-would-include","errorCode":null,"errorMessage":"Cannot push branch '{}': the push would include {} conflicted commit{}.\nConflicted commits: {}\nPlease resolve conflicts before pushing using 'but resolve <commit>'.","messagePattern":"Cannot push branch '(.+?)': the push would include (.+?) conflicted commit(.+?)\\.\nConflicted commits: (.+?)\nPlease resolve conflicts before pushing using 'but resolve <commit>'\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1258,"sourceCode":"        .map(|c| c.id)\n        .collect();\n    if conflicted.is_empty() {\n        return Ok(());\n    }\n    let repo = ctx.repo.get()?.clone().for_commit_shortening();\n    // Only pay for the map when the error actually prints.\n    let id_map = crate::IdMap::legacy_new_from_context(ctx).ok();\n    let conflicted_commits: Vec<String> = conflicted\n        .iter()\n        .map(|id| {\n            id_map\n                .as_ref()\n                .and_then(|id_map| id_map.change_id_ref(*id))\n                .map(|change_id| change_id.padded_short_id())\n                .unwrap_or_else(|| shorten_object_id(&repo, *id))\n        })\n        .collect();\n    Err(anyhow::anyhow!(\n        \"Cannot push branch '{}': the push would include {} conflicted commit{}.\\n\\\n             Conflicted commits: {}\\n\\\n             Please resolve conflicts before pushing using 'but resolve <commit>'.\",\n        branch_name,\n        conflicted_commits.len(),\n        if conflicted_commits.len() == 1 {\n            \"\"\n        } else {\n            \"s\"\n        },\n        conflicted_commits.join(\", \")\n    ))\n}\n\n#[cfg(test)]\nmod tests {\n    use super::branch_remote_ref_for_display;\n    use gitbutler_git::PushResult;","sourceCodeStart":1240,"sourceCodeEnd":1276,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1240-L1276","documentation":"`check_for_conflicted_commits` blocks a push when any commit in the branch being pushed is still in a conflicted state (conflicts stored by GitButler's conflict stack). GitButler intentionally refuses to publish conflicted commits and directs the user to resolve them first with `but resolve <commit>`.","triggerScenarios":"`but push` (push_single_branch_impl) on a branch whose commit range includes one or more commits with unresolved merge conflicts — detected by mapping conflicted commit ids to change ids via the workspace's id map.","commonSituations":"User pulled/rebased with conflicts, chose to keep working without resolving, then pushes; automated scripts pushing stacks after an apply that left conflicts; forgetting which commits still carry conflict markers.","solutions":["Run `but resolve <commit>` for each listed conflicted commit and resolve the conflicts","Check `but status` to find remaining conflicted files/commits and resolve them","Re-run the push after all conflicts are resolved","If scripting, fail early by checking for conflicts before invoking push"],"exampleFix":"// before\nbut push branch-with-conflicts\n// error: push would include 1 conflicted commit\n// after\nbut resolve <commit-id>\nbut push branch-with-conflicts","handlingStrategy":"validation","validationCode":"// resolve all conflicts before pushing\nbut status | grep -i conflict && { echo 'Resolve first: but resolve <commit>'; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! but push \"$BRANCH\" 2>&1; then\n  echo \"Push blocked - resolve conflicted commits listed above with: but resolve <commit>\"\n  exit 1\nfi","preventionTips":["Resolve conflicts immediately after apply/rebase, before staging other work","Run `but status` as a pre-push check in scripts","Keep stacks small so conflicts are rare and visible"],"tags":["git-push","merge-conflict","conflict-resolution","cli"],"backgroundTag":"invalid-state-transition","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}