Git Bundle
一句话解释
git bundle 把提交与引用打包为单个二进制文件,可从中克隆或拉取,适合离线。
用大白话说
git bundle 创建一个含 Git 对象(提交、树、blob)与引用的单文件,可作为 git clone 或 git fetch 的来源。它是在无网络下传输仓库数据的方式——你可用 U 盘移动 bundle 再从中克隆。用 git bundle create repo.bundle main 创建,打包从 main 分支可达的一切。可打包范围(git bundle create update.bundle main..feature)仅发送新提交。接收方用 git bundle verify 校验,再从 bundle 文件路径 fetch 或 clone。适用场景:离线协作(经物理介质传代码)、创建备份快照、经气隙网络传输仓库,以及无法推到共享远程时把分支发给同事。bundle 自包含且可移植。
示例
bash
# On machine A — create a bundle of the main branch
git bundle create repo.bundle main
# Copy repo.bundle to a USB stick or email
# On machine B — verify and clone from the bundle
git bundle verify repo.bundle
git clone repo.bundle my-project
# Send only new commits since the last bundle
git bundle create update.bundle old-main..main
# Receiver fetches the update
git fetch update.bundle main:maincreate 把对象打包进文件。verify 检查 bundle 有效且有必需前提。clone/fetch 把 bundle 文件当远程。
相关术语
相关资源
相关课程
- Git 进阶
学习 git bundle。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。