I was asking an agent to find out when a function in my own website's repository had changed its behavior. The answer came back: "This file was newly created in the most recent commit. There is no earlier history."
That file had been growing for months. When I ran git log on my iMac, nearly twenty changes were sitting right there.
The cause was the working copy. I had prepared it with git clone --depth 1 to save time, and to the agent that meant living in a world with only one commit of history. The uncomfortable part is that git usually doesn't tell you this with an error.
Four ways to clone the same repository
To see how big the gap really was, I cloned the same repository (a Next.js site with 2,434 commits) four ways and recorded the time and the size of .git. This was on a Linux work environment with git 2.34.1, two runs each.
| Mode | Option | Clone time | .git size | Local commits |
|---|---|---|---|---|
| shallow | --depth 1 | 2.79s / 2.81s | 18MB | 1 |
| blobless | --filter=blob:none | 4.54s / 4.47s | 21MB | 2,434 |
| treeless | --filter=tree:0 | 3.98s / 4.00s | 18MB | 2,434 |
| full | (none) | 10.20s / 10.14s | 39MB | 2,434 |
On speed alone, shallow wins easily — about a quarter of a full clone. That difference is exactly why I reached for it in the first place.
Here is the script I used. Swap in your own repository URL and you'll get the same table for your project.
#!/usr/bin/env bash
# Compare clone time and .git size across clone modes
set -u
URL="${1:?pass a repository URL}"
WORK="$(mktemp -d)"
cd "$WORK"
for mode in "shallow:--depth 1" "blobless:--filter=blob:none" "treeless:--filter=tree:0" "full:"; do
name="${mode%%:*}"; opts="${mode#*:}"
start=$(date +%s.%N)
# treeless can hang on later commands, so cap the clone itself too
timeout 300 git clone -q $opts "$URL" "$name" || { echo "$name: clone failed"; continue; }
end=$(date +%s.%N)
printf "%-9s %6.2fs .git=%sMB commits=%s\n" "$name" "$(echo "$end - $start" | bc)" \
"$(du -sm "$name/.git" | cut -f1)" "$(git -C "$name" rev-list --count HEAD)"
done
echo "work dir: $WORK"The timeout is there because the treeless clone caught me once, as you'll see below.
Five commands agents run all the time
What mattered more than clone speed was whether the answers were right when the agent later asked about history. I picked five commands agents commonly run while investigating or fixing something, and ran each in all four working copies against the file that had been called "newly created."
| Command | shallow | blobless | treeless | full |
|---|---|---|---|---|
git log --oneline -20 | only 1 | 20 | 20 | 20 |
git diff --stat HEAD~5 | fatal (no HEAD~5) | 0.63s | 1.11s | 0.17s |
git log -- file | 1 (wrong) | 19, 0.04s | killed at 90s | 19, 0.04s |
git blame file | all 234 lines on 1 commit | 5 commits, 1.70s | (not measured) | 5 commits, 0.03s |
git log -p -3 -- file | whole file shown as added | correct diff | (not measured) | correct diff |
The shallow column is where I stopped. Only git diff HEAD~5 failed loudly. The other four quietly returned wrong answers as if nothing were off.
In git blame, every one of the 234 lines started with ^. That caret is git's boundary marker — "nothing before this commit exists here" — but to an agent reading the output, it's just one more character. git log -p showed the entire file under new file mode 100644. Concluding "created in the last commit" was, honestly, a perfectly reasonable reading.
Treeless had its own trap. A path-limited git log fetched trees one commit at a time and still hadn't finished after 90 seconds. If your agent's terminal ever sits at "running" forever, this shape is worth suspecting.
Deepening after the fact
I also checked whether a shallow working copy can be repaired later.
| Operation | Time | Result |
|---|---|---|
git fetch --deepen=50 | 0.77s | The HEAD~5 diff now worked. But blame for the target file still put every line on the boundary commit |
git fetch --unshallow | 9.69s | All 2,434 commits arrived and blame became correct. .git grew to 51MB — larger than a fresh full clone (39MB) |
--deepen=50 fixes answers within the last 50 commits. For a file whose changes are older than that, blame is still wrong. "I deepened it a bit" isn't the same as "it's safe now."
--unshallow is reliable, but it took about as long as a full clone and left more on disk. In the end, you pay back the seconds you saved, roughly in full.
Where I draw the line now
After this, I split working copies by task. As a single rule:
Earn speed at clone time, but never let a shallow copy answer a history question.
| What I ask the agent to do | Clone I use |
|---|---|
| Build, test, small fixes to the latest code | shallow (--depth 1) |
| "When and why did this change?", blame, regression hunting | blobless (--filter=blob:none) |
| bisect, or sweeping history across many files | full clone |
treeless (--filter=tree:0) | not used for agents |
Blobless clones in roughly half the time of a full clone and still gives correct history. Blame takes a second or two because it fetches content on demand, which feels cheap compared with a confident wrong answer.
I also added a small script that checks depth before any history command. In the agent's instruction file I wrote: run this before investigating history, and if it prints SHALLOW, report back instead of answering.
#!/usr/bin/env bash
# history-check.sh — check depth and missing objects before asking about history
set -eu
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
echo "SHALLOW: only $(git rev-list --count HEAD) commit(s) available locally"
echo " blame / log -- <file> / log -p answers cannot be trusted"
echo " fix: git fetch --unshallow (or re-clone as blobless)"
exit 2
fi
filter="$(git config --get remote.origin.partialclonefilter || true)"
case "$filter" in
tree:*) echo "TREELESS: path-limited log may stall for a long time"; exit 3 ;;
blob:none) echo "BLOBLESS: history is reliable (first blame takes a few seconds)" ;;
*) echo "FULL: no restrictions" ;;
esacI keep exit 2 and exit 3 separate so the agent can choose its next step from the exit code alone. The wording on stdout may drift over time; exit codes are something it can branch on.
git rev-parse --is-shallow-repository returns true for a shallow clone. The partial clone type is stored in remote.origin.partialclonefilter, so reading it tells you whether you're blobless or treeless.
Stepping back
Within the world it's given, an agent reasons very faithfully. Missing the ^ marker wasn't carelessness on its part; I simply hadn't told it that it was looking at a partial history.
When I choose a faster tool, I'd rather also hand over what that speed hides — I think that part is the job of the one delegating.
As an indie developer, the next step I'd suggest is small: run git rev-parse --is-shallow-repository once in your agent's working copy. If it says true, revisit just one history-related answer your agent gave recently. The "newly created" file at the top of this post is what I found when I did exactly that.
I wrote about what goes missing in throwaway workspaces like /boost in "Before I accept what /boost says it verified, I count what its throwaway worktree never saw." For designing and costing a read-only .git handed to an agent, "Reading the Same History in 38 Seconds — or 0.4: Handing a Read-Only .git to Your Agent" goes one level deeper.