# Git Config Get: read one setting

Published: 2026-11-30

Rights: original
Source: https://kairos-2z6s.onrender.com/res/git-config-get-full-en
`git config --get KEY` prints the value of one setting (the current docs write this as `git config get KEY`). The recorded Git is 2.34.1. For a key that is not set it exits with status 1; the docs say get "Returns error code 1 if key is not present". This run uses the `--get` form and shows 1. `git config KEY VALUE` is the older form of `git config set KEY VALUE` and writes a value into the repository configuration.

Each command below is the exact command that was run and each output block is copied from the recorded log. Test ids, log hashes and exit statuses are in the evidence table.

(Test: 3 tests were run, TE-91-A, TE-91-B and TE-91-C. The expected non-zero exit is TE-91-C (exit status 1). Every row has a recorded log, and the exit statuses and log hashes are in the evidence table.)

### TE-91-A: config sets a value, --get reads it, and --get of an unset key exits with status 1

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
git init -q .
git symbolic-ref HEAD refs/heads/main
git config user.email test@example.invalid
git config user.name tester
git config commit.gpgsign false
```

Command:

```bash
git config demo.name demo; git config --get demo.name; echo rc=$?; git config --get demo.missing; echo rc=$?
```

Recorded output:

```
demo
rc=0
rc=1
```

Exit status: 0. The output matches the expected text written before the run.

### TE-91-B: git config --unset removes a setting, and --get then exits with status 1

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
git init -q .
git symbolic-ref HEAD refs/heads/main
git config user.email test@example.invalid
git config user.name tester
git config commit.gpgsign false
git config demo.name demo
```

Command:

```bash
git config --unset demo.name; echo rc=$?; git config --get demo.name; echo rc=$?
```

Recorded output:

```
rc=0
rc=1
```

Exit status: 0. This status and the output match what was written before the run.

### TE-91-C: expected non-zero exit: git config --get with a key that has no section prints an error and exits with status 1

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
git init -q .
git symbolic-ref HEAD refs/heads/main
git config user.email test@example.invalid
git config user.name tester
git config commit.gpgsign false
```

Command:

```bash
git config --get bad
```

Recorded output: none, standard output was empty.

Standard error from the same run:

```
error: key does not contain a section: bad
```

Exit status: 1. This status and the output match what was written before the run.

## Reading the recorded output

The first read prints demo, the value just written to demo.name, and rc=0 is the exit status of that read. The second read asks for demo.missing, a key that was not set. It prints nothing and gives rc=1. In this run the exit status, not the output, is what reports the missing key.

TE-91-B: by the setup, demo.name was set. --unset exited with status 0, and --get demo.name after it exited with status 1 and printed nothing. TE-91-C: git config --get bad exited with status 1, and standard error reads error: key does not contain a section: bad.

## Limits

Only the repository configuration file was used. The recorded Git is 2.34.1. Global and system files were not tested.

## Source

- https://git-scm.com/docs/git-config

## Evidence table

| Test | What it checks | Exit | Verdict | Log sha256 (first 12) |
|---|---|---|---|---|
| `TE-91-A` | config sets a value, --get reads it, and --get of an unset key exits with status 1 | 0 | PASS | `e81702f4407a` |
| `TE-91-B` | git config --unset removes a setting, and --get then exits with status 1 | 0 | PASS | `2c6a514e31f8` |
| `TE-91-C` | expected non-zero exit: git config --get with a key that has no section prints an error and exits with status 1 | 1 | PASS | `42ec4feb861d` |

Recorded on: bash 5.1.16(1)-release; git version 2.34.1; Python 3.10.12. Locale C.UTF-8, TZ=UTC.
Every row has a recorded log holding the setup commands, the command, stdout, stderr and exit status. The first 12 characters of the log's sha256 are in the table.

## Related guides
- [Git Commit Allow Empty: a commit with no changes](https://kairos-2z6s.onrender.com/res/git-commit-allow-empty-full-en)
- [Git Ls Files: list what Git tracks](https://kairos-2z6s.onrender.com/res/git-ls-files-full-en)
- [Git Describe: name a commit from the nearest tag](https://kairos-2z6s.onrender.com/res/git-describe-full-en)
- [Git Commit Fixup: correct an earlier commit](https://kairos-2z6s.onrender.com/res/git-commit-fixup-full-en)
- [Git Blame: who last changed each line](https://kairos-2z6s.onrender.com/res/git-blame-full-en)
