◉ANTIGRAVITY LABJP
Articles/AI Tools
⚙ AI Tools/2026-11-22Beginner

In a --depth 1 working copy, git blame pinned all 234 lines on a single commit. Choosing the clone you hand to an agent

I cloned the same repository four ways (shallow, blobless, treeless, full) and compared clone time with what log, diff, and blame actually return. A shallow clone often gives wrong history without any error. Here is how I pick a clone per task, plus a short script that checks depth first.

git18shallow clonepartial cloneagents152git blame

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.

ModeOptionClone time.git sizeLocal commits
shallow--depth 12.79s / 2.81s18MB1
blobless--filter=blob:none4.54s / 4.47s21MB2,434
treeless--filter=tree:03.98s / 4.00s18MB2,434
full(none)10.20s / 10.14s39MB2,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."

Commandshallowbloblesstreelessfull
git log --oneline -20only 1202020
git diff --stat HEAD~5fatal (no HEAD~5)0.63s1.11s0.17s
git log -- file1 (wrong)19, 0.04skilled at 90s19, 0.04s
git blame fileall 234 lines on 1 commit5 commits, 1.70s(not measured)5 commits, 0.03s
git log -p -3 -- filewhole file shown as addedcorrect 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.

OperationTimeResult
git fetch --deepen=500.77sThe HEAD~5 diff now worked. But blame for the target file still put every line on the boundary commit
git fetch --unshallow9.69sAll 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 doClone I use
Build, test, small fixes to the latest codeshallow (--depth 1)
"When and why did this change?", blame, regression huntingblobless (--filter=blob:none)
bisect, or sweeping history across many filesfull 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" ;;
esac

I 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.

Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

⚙ AI Tools2026-10-01
You Don't Need to Read Commands: Three Places to Check When an Agent Works
If strings of terminal text make the approve button feel risky, here is a way to check just three things: a way back before you start, the first word of a command, and the diff afterward.
⚙ AI Tools2026-08-19
When Antigravity Swaps Its Default Model, Only the Jobs You Narrowed First Survive
Gemini 3.7 Flash is now the default model for Antigravity agents. The places you never configured are exactly the places that shift silently. Here is how to inventory your default-model exposure, then split your jobs into move-now and hold, scored by how much output freedom you left open.
⟐ Editor View2026-09-03
How much of Antigravity's generated commit message I actually keep
Where the Review pane's generated commit message stops being enough, and where I start writing. A prepare-commit-msg and commit-msg pair that adds and enforces a Why trailer, plus measured behaviour during rebase, cherry-pick, amend and revert.