美文网首页Git
git - 命令 archive

git - 命令 archive

作者: ReidLee | 来源:发表于2018-01-31 15:15 被阅读0次

    查看命令帮助,如下

    $  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^)

    相关文章

      网友评论

        本文标题:git - 命令 archive

        本文链接:https://www.haomeiwen.com/subject/tltlzxtx.html