Von Gast (nicht überprüft) , 29 April 2026

Die Kosten vollstandiger Klone

Ein vollstandiger Klon eines lang lebenden Repositorys kann hunderte von Megabyte sein. Bei jedem CI-Job.

Shallow-Clone-Grundlagen

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

Shallow mit mehreren Branches

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

Partielle Klone (Git 2.22+)

git clone --filter=blob:none https://example.com/repo.git
git clone --filter=tree:0 https://example.com/repo.git

Shallow und Partial kombinieren

git clone --depth=1 --filter=blob:none https://example.com/repo.git

GitHub Actions Beispiel

- uses: actions/checkout@v4
  with:
    fetch-depth: 1

- name: Get full history when needed
  run: git fetch --unshallow

Limitierungen von Shallow

  • Sie konnen nicht aus einem Shallow Clone in ein anderes Repo pushen ohne unshallow.
  • Einige Operationen sind unmoglich.
  • Forks und komplexe Submodul-Setups konnen schlecht interagieren.

Messen

time git clone --depth=1 https://example.com/repo.git
time git clone https://example.com/repo.git

Ergebnis cachen

if [ -d .git ]; then
  git fetch --depth=1
  git reset --hard FETCH_HEAD
else
  git clone --depth=1 ...
fi