Par Anonyme (non vérifié) , 29 avril 2026

Deux formats, deux objectifs

git archive produit un instantané tar ou zip d'un tree — code sans histoire, parfait pour les releases. git bundle produit un fichier de transport portable contenant des objets et refs — parfait pour le transfert offline d'un repo entier.

Exemples archive

git archive --format=tar.gz -o release-1.0.tar.gz v1.0.0
git archive --format=zip --prefix=myapp-1.0/ -o myapp-1.0.zip HEAD
git archive --format=tar HEAD src/ | tar -xC /tmp/snapshot

Exclure des fichiers

tests/      export-ignore
.github/    export-ignore
*.dev.json  export-ignore

Bundle pour transfert offline

git bundle create repo.bundle --all
git bundle create incr.bundle main ^origin/main
git bundle verify repo.bundle
git clone repo.bundle myrepo
git fetch repo.bundle main:imported

Cas d'usage : envoyer à client sous embargo

git bundle create v1.2.bundle main --tags
git fetch v1.2.bundle '+refs/heads/*:refs/remotes/upstream/*' '+refs/tags/*:refs/tags/*'

Archives reproductibles

git archive --format=tar.gz \
  --output=src.tar.gz \
  --prefix=src/ HEAD

Erreurs courantes

Confondre git archive (sans histoire) avec git bundle (histoire complète). Oublier --prefix produisant une "tarbomb."