查看命令帮助,如下
$ 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
运行git archive --list 查看支持的归档格式:
$ git archive --list
tar
tgz
tar.gz
zip
导出最新的版本库
git archive -o ../latest.zip HEAD
导出指定提交记录
git archive -o ../version-1.0.0.tar 9976c24
导出一个目录
git archive -o ../version-1.0.0-codes.zip HEAD:src/
导出为tar.gz格式
git archive 9976c24 | gzip > ../version-1.0.0.tar.gz
导出最后一次提交修改过的文件
git archive -o ../lastcommit.zip HEAD $(git diff --name-only HEAD^)
网友评论