归档 Git 仓库
下载地址
https://www.zhengdianxue.com/wp-content/uploads/skills/xzsmtech--git-bundle.zip将提示词发送给你的 AI 安装该 skills
请根据 https://skillhub.cn/install/skillhub.md,安装 @xzsmtech/git-bundle。将远端平台的 git 仓库打包为 .bundle 归档文件。克隆远端仓库的镜像,创建包含所有分支和标签的 git bundle,清理临时文件并验证生成的 bundle 文件完整性。
阅读全文 (展开查看完整说明)
概述
git-bundle
将远端 git 仓库打包为 bundle 文件,用于归档。
使用方式
/git-bundle https://github.com/user/repo.git
/git-bundle https://github.com/user/repo.git my-archive参数
$1— git-repo-url(必填):远端 git 仓库的克隆 URL(支持 https 和 ssh 协议)$2— bundle-name(可选):生成的 bundle 文件名(不含后缀)。若不提供,默认使用仓库名
步骤
- 解析参数:从
$ARGUMENTS中提取 URL 和可选的 bundle 名称。- 如果提供了 bundle 名称,则输出文件为
<bundle-name>.bundle - 如果未提供 bundle 名称,则从 URL 中提取仓库名(如
https://github.com/user/repo.git→repo),输出文件为<repo-name>.bundle
- 如果提供了 bundle 名称,则输出文件为
- 克隆镜像:执行
git clone --mirror "$URL" repo.git - 创建 bundle:进入
repo.git目录,执行git bundle create "../$BUNDLE" --all --tags,将所有分支和标签打包 - 验证 bundle:仍在
repo.git目录内,执行git bundle verify "../$BUNDLE"确认归档文件完整可用(git bundle verify必须在 git 仓库中运行) - 清理临时文件:退出临时目录,执行
rm -rf repo.git删除克隆的镜像仓库 - 报告结果:告知用户 bundle 文件已生成,输出文件路径和验证结果
注意事项
- 确保目标机器上已安装 git 且可访问远端仓库
- 生成的 bundle 文件位于当前工作目录
- 该文件可用于
git clone <bundle-file>还原仓库