gitbutlerapp/gitbutler · error

Could not read repository-local Git configuration

Error message

Could not read repository-local Git configuration: {}

What it means

selected_local_config runs `git config --local --get-regexp '^(gitbutler\.|remote\.|log\.excludedecoration$)'` to snapshot repository-local config for the dump. If git exits non-zero with any code other than 1 (1 means 'no matches', which is tolerated), the function bails including git's trimmed stderr.

Solutions

  1. Read the stderr in the message; fix the underlying git config problem it reports
  2. Validate .git/config with `git config --local --list` and repair any syntax errors
  3. Check file permissions on .git/config for the user running the dump
  4. If you intentionally have no matching keys, note exit code 1 is already tolerated — only other failures raise this

Example fix

// before
// .git/config contains a syntax error -> git exits 128
let cfg = installer.selected_local_config(repo_path)?;
// after
// fix config first:
//   git config --local --list   # reproduce the parse error
// repair the bad line, then:
let cfg = installer.selected_local_config(repo_path)?;
Defensive patterns

Strategy: try-catch

Validate before calling

let ok = Command::new("git").args(["config", "--local", "--list"])
    .current_dir(&repo_path).output()?.status.success();
if !ok { anyhow::bail!("repository-local git config is unreadable/corrupt"); }

Try / catch

match installer.selected_local_config(&repo_path) {
    Err(e) if e.to_string().contains("Could not read repository-local Git configuration") => {
        eprintln!("fix .git/config: {e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling selected_local_config (from run) where the `git config --local --get-regexp` process fails with an unexpected exit code — typically a corrupt or unreadable .git/config file.

Common situations: Malformed repository-local config (syntax error in .git/config), permission problems reading the config file, or a broken GIT_CONFIG environment pointing git at an inaccessible config.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/44bb695087309e35. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-debug/src/command/dump/repo_installer.rs:210

        );
    }
    Ok(())
}

fn selected_local_config(workdir: &Path) -> Result<Vec<u8>> {
    let output = git_command(workdir)?
        .args([
            "config",
            "--local",
            "--includes",
            "--null",
            "--get-regexp",
            r"^(gitbutler\.|remote\.|log\.excludedecoration$)",
        ])
        .output()
        .context("Could not read repository-local Git configuration")?;
    if !output.status.success() && output.status.code() != Some(1) {
        bail!(
            "Could not read repository-local Git configuration: {}",
            String::from_utf8_lossy(&output.stderr).trim()
        );
    }

    let mut selected = Vec::with_capacity(output.stdout.len());
    for record in output.stdout.split(|byte| *byte == 0) {
        if record.is_empty() {
            continue;
        }
        let key_end = record
            .iter()
            .position(|byte| *byte == b'\n')
            .context("Git configuration record did not contain a value")?;
        let key = &record[..key_end];
        if is_storage_path_key(key) {
            continue;
        }

View on GitHub (pinned to 58e5313667)