GitoxideLabs/gitoxide · error
cannot amend with unresolved index conflicts
Error message
cannot amend with unresolved index conflicts
What it means
When amending the head commit, tix loads the index and rejects the operation if any index entry is at a non-Unconflicted stage, i.e. there are unresolved merge conflicts. Committing an amend from a conflicted index would produce a broken commit, so it fails fast.
Solutions
- Resolve all conflicts and stage them (`git add <paths>`) before amending.
- Abort the in-progress merge/rebase and redo the operation on a clean state.
- Verify with `git status` (no 'Unmerged paths') that the index is conflict-free first.
Example fix
// guard before amend
let index = repo.index_or_empty()?;
if index.entries().iter().any(|e| e.stage() != gix::index::entry::Stage::Unconflicted) {
anyhow::bail!("resolve index conflicts first");
}
head::perform(&repo, Kind::Amend, None, ...)?; Defensive patterns
Strategy: validation
Validate before calling
let index = repo.index_or_empty()?;
let conflicted = index.entries().iter()
.any(|e| e.stage() != gix::index::entry::Stage::Unconflicted);
if conflicted {
anyhow::bail!("cannot amend: resolve index conflicts first");
} Try / catch
match result {
Err(e) if e.to_string().contains("cannot amend with unresolved index conflicts") => {
eprintln!("resolve conflicts and stage them, then amend again");
}
other => other?,
} Prevention
- Only amend on a conflict-free index; check `git status` first.
- Finish or abort in-progress merges/rebases before edit operations.
- Add an index-conflict assertion to any automation calling amend.
When it happens
Trigger: `perform_inner` (reached via `perform`, `perform_with_changes`, `perform_reporting`, `amend_index`, `amend_index_reporting`) runs while the index contains conflict stages — mid-merge/rebase with unresolved paths.
Common situations: Issuing a `tix` amend right after a conflicted merge; resuming scripted edits after an interrupted rebase; forgetting that `git add` was never run on resolved files.
Related errors
- a tree change cannot be amended from the worktree
- an edit unexpectedly produced a merge conflict
- cannot create a commit with unresolved index conflicts
- cannot spill an unmerged path
- cannot split with unresolved conflicts
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/dde963517e0b2bfc.
Report an issue: GitHub.
Appendix: source
Thrown at gix-tix/src/edit/head.rs:106
(Kind::Amend, Some(([path], _))) => Some(path),
(Kind::Amend, Some(_)) => anyhow::bail!("amending requires exactly one selected path"),
_ => None,
};
let tree = match kind {
Kind::Spill => match selected_paths {
Some((paths, selected_parent)) => {
spill_paths_tree(&repo, old_tree, selected_parent.unwrap_or(parent_tree), paths)?
}
None => parent_tree,
},
Kind::Amend => {
let index = repo.index_or_empty().context("could not load the index")?;
if index
.entries()
.iter()
.any(|entry| entry.stage() != gix::index::entry::Stage::Unconflicted)
{
anyhow::bail!("cannot amend with unresolved index conflicts");
}
if let Some(path) = selected_amend_path {
if review && path.group != crate::ChangeGroup::Staged {
anyhow::bail!("review commits can amend only staged paths");
}
amend_path_tree(&repo, old_tree, path, &index)?
} else if review || index_only {
let index_tree = create::index_tree(&repo, &index)?;
if index_tree == old_tree && !pending {
return Ok(None);
}
index_tree
} else {
let index_tree = create::index_tree(&repo, &index)?;
if index_tree != old_tree {
index_tree
} else {
let baseline = repo.find_tree(old_tree)?;View on GitHub (pinned to e73179060b)