网站首页 > 精选文章 正文
我有一个 Git 仓库,想把其中的源代码打包成 zip 压缩包。
方法一:使用 zip 命令
如果直接使用如下命令:
zip -r sources.zip .
会把 .git/ 目录和 node_modules/ 打包进去 zip 文件。前者包含所有的代码提交历史,后者包含依赖 node 依赖包,体积巨大。
为了排除这两个文件,可以使用 -x 选项。
zip -r sources.zip . -x '*node_modules*' -x '*.git*'
要查看压缩包的文件列表,使用 unzip 命令。
unzip -l sources.zip
方法二:使用 git archive 命令
git archive 命令可以把指定分支输出为特定的格式。它的语法如下:
git archive --format=<fmt> --outout=<file> <path>
git archive 打包时会自动排除被 .gitignore 忽略的文件。
假如我们想把 master 分支的代码,打包为 master.zip 的话,执行语句如下:
git archive --format=zip --output=master.zip master
这种方法可以把 .gitignore 打包到压缩包中。
- 上一篇: 不同主机迁移git仓库Gitolite
- 下一篇: 微软开源Scalar 提升操作巨型Git仓库的速度
猜你喜欢
- 2025-01-20 将 node_modules 目录放入 Git 仓库的优点
- 2025-01-20 微软开源Scalar 提升操作巨型Git仓库的速度
- 2025-01-20 不同主机迁移git仓库Gitolite
- 2025-01-20 同步GIT仓库的操作 -- fetch命令
- 2025-01-20 git log 命令用法实例 (2)
- 2025-01-20 还在为 Git 仓库瘦身头疼?快来试试 repo-clean
- 2025-01-20 自建Git服务器 - 创建属于你自己的代码仓库,开启你的Git私服之旅
- 2025-01-20 中央仓库管理-基于工作空间和git-submodule实现共用和管理
- 2025-01-20 从零开始,小白也能学会的创建Git仓库实操
- 2025-01-20 无公网搭建私有GIT同步仓库思路
- 最近发表
- 标签列表
-
- 向日葵无法连接服务器 (32)
- git.exe (33)
- vscode更新 (34)
- dev c (33)
- git ignore命令 (32)
- gitlab提交代码步骤 (37)
- java update (36)
- vue debug (34)
- vue blur (32)
- vscode导入vue项目 (33)
- vue chart (32)
- vue cms (32)
- 大雅数据库 (34)
- 技术迭代 (37)
- 同一局域网 (33)
- github拒绝连接 (33)
- vscode php插件 (32)
- vue注释快捷键 (32)
- linux ssr (33)
- 微端服务器 (35)
- 导航猫 (32)
- 获取当前时间年月日 (33)
- stp软件 (33)
- http下载文件 (33)
- linux bt下载 (33)