git log: commits reachable from HEAD, and --all
git log lists the commits reachable from HEAD; --all adds commits reachable from other branches. The run shows the default count and the --all count. TE-13-A shows both counts and TE-13-B shows --grep with one pattern. Filtering by file, count or content (a path, -n, -S, -G) is not tested on this page.
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.
TE-13-A: git log defaults to commits reachable from HEAD; --all adds other branches
Setup for this run, inside a throwaway directory (mktemp -d):
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
printf 'one\n' > f.txt; git add f.txt; git commit -qm one
git checkout -q -b other; printf 'two\n' > o.txt; git add o.txt; git commit -qm two
git checkout -q -Command:
echo default=$(git log --oneline | wc -l); echo all=$(git log --all --oneline | wc -l)Recorded output:
default=1
all=2TE-13-B: git log --grep keeps only the commits whose message matches the text
Setup for this run, inside a throwaway directory (mktemp -d):
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
printf 'one\n' > f.txt; git add f.txt; git commit -qm one
printf 'two\n' > f.txt; git add f.txt; git commit -qm two
printf 'three\n' > f.txt; git add f.txt; git commit -qm threeCommand:
git log --grep=t --format=%sRecorded output:
three
twoExit status: 0. This status and the output match what was written before the run.
TE-13-C: expected non-zero exit: git log with a name that is not a branch or commit stops with a fatal error
Setup for this run, inside a throwaway directory (mktemp -d):
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
printf 'one\n' > f.txt; git add f.txt; git commit -qm oneCommand:
git log nosuchbranchRecorded output: none, standard output was empty.
Standard error from the same run:
fatal: ambiguous argument 'nosuchbranch': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'Exit status: 128. This status and the output match what was written before the run.
Reading the recorded output
The value default=1 is the number of lines that git log --oneline printed on the current branch. The value all=2 is the number printed by git log --all --oneline. By the setup, the second commit was made on the branch other and the run then went back to the first branch with checkout -, so the extra line in the --all count is the commit on other.
TE-13-B: by the setup, the commit messages are one, two and three. git log --grep=t --format=%s printed three and then two. The message one has no t, so it was left out. TE-13-C: git log nosuchbranch exited with status 128 and printed fatal: ambiguous argument 'nosuchbranch': unknown revision or path not in the working tree. to standard error.
Limits
The run shows the default count and the --all count. Per the git documentation, -S and -G search for content changes; neither is tested here.
Source
Evidence
TE-13-A: git log defaults to commits reachable from HEAD; --all adds other branches
- logs: one recorded log for each row above
- Recorded on: Linux x86_64, kernel 7.3.4; bash 5.1.16; git 2.34.1; python 3.10.12; findutils 4.8.0; grep 3.7; sed 4.8; gawk 5.1.0; tar 1.34; curl 7.81.0. Locale C.UTF-8, TZ=UTC.
Evidence table
| Test | What it checks | Exit | Verdict | Log sha256 (first 12) | |---|---|---|---|---| | TE-13-A | git log defaults to commits reachable from HEAD; --all adds other branches | 0 | PASS | 52e87f5924c3 | | TE-13-B | git log --grep keeps only the commits whose message matches the text | 0 | PASS | 9e166c618a89 | | TE-13-C | expected non-zero exit: git log with a name that is not a branch or commit stops with a fatal error | 128 | PASS | be332a3d546e |
Every row has a recorded log holding the setup commands, the command, stdout, stderr, exit status and the final directory state. The first 12 characters of the log's sha256 are in the table.
All full guides: All guides