GitoxideLabs/gitoxide · error · anyhow::Error
Without refspecs there is nothing to show here. Add…
Error message
Without refspecs there is nothing to show here. Add refspecs as arguments or configure them in .git/config.
What it means
`print_refmap` bails out when the effective refspec list is empty, because a ref-mapping report needs at least one fetch refspec to map remote refs to local tracking refs. Without refspecs (from CLI arguments or `.git/config`) there is nothing to map or print. This is a user-input completeness check rather than an internal failure.
Solutions
- Pass refspecs as CLI arguments, e.g. `gix refs refs/heads/*:refs/remotes/origin/*`
- Add fetch refspecs to `.git/config` under `remote.<name>.fetch` (e.g. `+refs/heads/*:refs/remotes/origin/*`)
- Verify the remote section exists in config with `git config --get-all remote.origin.fetch`
- Re-add the remote properly (`git remote add origin <url>`) which restores default refspecs
Example fix
// before (no refspecs anywhere) gix refs --tracking // after gix refs --tracking 'refs/heads/*:refs/remotes/origin/*'
Defensive patterns
Strategy: validation
Validate before calling
# ensure refspecs exist before invoking git config --get-all remote.origin.fetch || echo 'refs/heads/*:refs/remotes/origin/*' >> local_cfg # or pass explicitly: [ -n "$REFSPEC" ] || REFSPEC='refs/heads/*:refs/remotes/origin/*' gix refs --tracking "$REFSPEC"
Try / catch
if ! gix refs --tracking "$spec" 2>err.log; then
grep -q 'Without refspecs' err.log && { echo 'configure remote.<name>.fetch first'; }
fi Prevention
- Always pass refspecs explicitly in scripts instead of relying on .git/config
- Verify `git config --get-all remote.<name>.fetch` is non-empty before running
- Re-create remotes with `git remote add` so default refspecs are written
- Never strip remote.*.fetch entries when editing config files
When it happens
Trigger: Calling `gix refs` (tracking mode, via refs_fn -> print_refmap) with no refspec arguments AND a repository whose `.git/config` has no configured fetch refspecs for the remote (e.g. after `git remote add` without fetching, or a config stripped of `remote.<name>.fetch`).
Common situations: Freshly cloned-with-no-fetch config, repositories created by tools that don't write `remote.*.fetch`, or users passing `--refspec` incorrectly so the parsed refspec list ends up empty.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Cannot run without any task to perform on the repositories
- At least one operation failed
- No commits to process
- Refusing to checkout index into existing directory
- Cannot print information using 'human' format.
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/c61e21d1fa647db2.
Report an issue: GitHub.
Appendix: source
Thrown at gitoxide-core/src/repository/remote.rs:264
map.remote_refs.len(),
map.remote_refs.len() - map.mappings.len(),
refspecs.len()
)?;
if show_unmapped_remotes {
writeln!(&mut out, "\nFiltered: ")?;
for remote_ref in map.remote_refs.iter().filter(|r| {
!map.mappings.iter().any(|m| match &m.remote {
Source::Ref(other) => other == *r,
Source::ObjectId(_) => false,
})
}) {
print_ref(&mut out, remote_ref)?;
writeln!(&mut out)?;
}
}
}
if refspecs.is_empty() {
bail!(
"Without refspecs there is nothing to show here. Add refspecs as arguments or configure them in .git/config."
)
}
Ok(())
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum JsonRef {
Peeled {
path: String,
tag: String,
object: String,
},
Direct {
path: String,
object: String,
},
Unborn {View on GitHub (pinned to e73179060b)