Da Anonimo (non verificato) , 29 Aprile 2026

Il trade-off shallow

Un clone shallow (--depth=N) scarica solo gli ultimi N commit. Piu veloce, piu piccolo, ma con caveat: molte operazioni dipendenti dalla storia diventano impossibili o sbagliate.

Invocazione base

git clone --depth=1 https://example.com/repo.git
git clone --depth=50 --no-tags https://example.com/repo.git
git clone --shallow-since=2024-01-01 https://example.com/repo.git
git clone --shallow-exclude=v1.0.0 https://example.com/repo.git

Single-branch

git clone --depth=1 --no-single-branch https://example.com/repo.git

Cosa si rompe

  • git log si ferma al confine shallow.
  • git blame assegna le modifiche piu profonde al commit confine.
  • git bisect puo cercare solo nella finestra shallow.
  • git merge-base puo fallire.

Promuovere dopo

git fetch --unshallow
git fetch --depth=1000
git fetch --shallow-since=2023-01-01

Pattern CI

git clone --depth=1 --no-tags --filter=tree:0 \
  --branch "$CI_COMMIT_REF_NAME" "$CI_REPOSITORY_URL" .

Quando evitare shallow

  • Build di release che incorporano git describe.
  • Scanner SBOM/license che camminano sull'authorship.
  • Step di bisect o blame in CI.

Errori comuni

Usare --depth=1 in una pipeline di release che esegue git describe e stampa v0.0.0-unknown.