git命令將程式碼匯出為單個檔案
阿新 • • 發佈:2021-01-12
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格式。