git命令将代码导出为单个文件
ming@xiaomingdeMacBook-Pro:~$ git archive
usage: git archive [<options>] <tree-ish> [<path>...]
or: git archive --list
or: git archive --remote <repo> [--exec <cmd>] [<options>] <tree-ish> [<path>...]
or: git archive --remote <repo> [--exec <cmd>] --list
--format <fmt> archive format
--prefix <prefix> prepend prefix to each pathname in the archive
-o, --output <file> write the archive to this file
--worktree-attributes
read .gitattributes in working directory
-v, --verbose report archived files on stderr
-0 store only
-1 compress faster
-9 compress better
-l, --list list supported archive formats
--remote <repo> retrieve the archive from remote repository <repo>
--exec <command> path to the remote git-upload-archive command
示例:
1、导出为zip格式压缩包
git archive -v --format=zip 分支名 -o 压缩包文件名
如:
git archive -v --format=zip v0.1 -o v0.1.zip
2、导出为tar格式文件
git archive -v --format=tar 分支名 -o 文件名
如:
git archive -v --format=tar v0.1 -o v0.1.tar
注:--format也可以不显式指明。git可以根据文件名的后缀自动判断,如果是.zip结尾,则是zip格式,否则输出为tar格式。
浙公网安备 33010602011771号