git - 命令 archive

查看命令帮助,如下

$  git archive

usage: git archive []  [...]
  or: git archive --list
  or: git archive --remote  [--exec ] []  [...]
  or: git archive --remote  [--exec ] --list

   --format         archive format
   --prefix      prepend prefix to each pathname in the archive
   -o, --output    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        retrieve the archive from remote repository 
   --exec       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^)

你可能感兴趣的:(git - 命令 archive)