gitbutlerapp/gitbutler · error · anyhow::Error
'{s}' does not name an uncommitted change or branch; refusin
Error message
'{s}' does not name an uncommitted change or branch; refusing to absorb everything What it means
When `but absorb` is given an explicit selector, the CLI resolves it against both uncommitted changes (resolve_uncommitted_part) and branch sources (parse_sources), then filters to UncommittedHunkOrFile/Branch IDs. If nothing acceptable remains, this error is raised deliberately — the comment in the source states silently falling back to absorbing everything is never intended. It means the selector string matched no uncommitted change and no branch.
Source
Thrown at crates/but/src/command/legacy/absorb.rs:61
let mut guard = ctx.exclusive_worktree_access();
let id_map = IdMap::new_from_context(ctx, guard.read_permission())?;
let source: Option<CliId> = source
.map(|s| -> anyhow::Result<CliId> {
// Uncommitted selectors resolve in the uncommitted namespace first
// so later commits cannot shadow them; branch selectors resolve in
// the full namespace. A selector that names neither is an error —
// silently falling back to absorbing everything is never intended.
let resolved =
match crate::id::parser::resolve_uncommitted_part(ctx, &id_map, s) {
Ok(ids) if !ids.is_empty() => ids,
_ => parse_sources(ctx, &id_map, s)?,
};
let mut acceptable = resolved.into_iter().filter(|id| {
matches!(id, CliId::UncommittedHunkOrFile { .. })
|| matches!(id, CliId::Branch(..))
});
let first = acceptable.next().ok_or_else(|| {
anyhow::anyhow!(
"'{s}' does not name an uncommitted change or branch; refusing to absorb everything"
)
})?;
if acceptable.next().is_some() {
anyhow::bail!(
"'{s}' is ambiguous - it matches more than one uncommitted change. Use more characters to disambiguate."
);
}
Ok(first)
})
.transpose()?;
let target = if let Some(source) = source {
match source {
CliId::UncommittedHunkOrFile(UncommittedHunkOrFile { hunks, .. }) => {
// Absorb this particular file
AbsorptionTarget::Hunks {
hunks: hunks.map(|id_and_hunk| id_and_hunk.hunk).into(),View on GitHub (pinned to caf1f223d3)
Solutions
- Run `but id` (or the equivalent listing) to refresh and see the currently valid selectors, then retry with one of them.
- If the change was already committed, absorb is the wrong operation — target the commit/branch directly instead.
- Use a longer, exact prefix of the listed ID or a path prefix that uniquely names a dirty file.
- If you actually meant 'absorb everything', omit the selector entirely; the guard exists to prevent accidental mass-absorption.
Example fix
# before: stale selector $ but absorb 3a Error: '3a' does not name an uncommitted change or branch; refusing to absorb everything # after: look up a live ID and retry $ but id $ but absorb 3a9f
Defensive patterns
Strategy: validation
Validate before calling
// Verify the selector resolves before running absorb
let id_map = IdMap::legacy_new_from_context(ctx)?;
let resolved = id_map.parse_using_context(selector, ctx)?;
let ok = resolved.iter().any(|id| matches!(id, CliId::UncommittedHunkOrFile { .. } | CliId::Branch(..)));
anyhow::ensure!(ok, "selector '{selector}' resolves to nothing absorbable"); Prevention
- Regenerate the ID map (`but id`) right before scripted absorb commands.
- Never reuse selectors from old shell history across worktree mutations.
- Use unique path prefixes for stability.
When it happens
Trigger: Calling absorb with a stale/mistyped prefix whose change has since been committed or discarded; using a plain branch name when branches aren't in the ID map; passing a file-path fragment that matches no current worktree hunk; selectors for entries in a different workspace's ID map.
Common situations: Re-running an old command from shell history after the worktree changed; abbreviating an ID with too few characters so it matches nothing (note: matching more than one raises the separate ambiguity error); ID maps from `but id` being stale after commits.
Related errors
- Invalid source: expected an uncommitted file or branch
- No ID found for entity
- Commit '{commit_id_str}' not found
- Could not find {kind} CLI id '{short_id}' in IdMap
- CLI id '{short_id}' is ambiguous for {kind} in IdMap
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/21fa452288cb48a0.
Report an issue: GitHub.