2014/10/03

如何做 “git export” (像 “svn export”)?



完成一個版本後想要發行

如果用git clone的話又會產生.git資料夾

以下提供如何做到像svn export一樣的功能

利用git archive
```
$ git archive -h
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 <cmd> path to the remote git-upload-archive command
```

使用方法1:
倒出master到某個資料夾

```
git archive master | tar -x -C /somewhere/else
```


使用方法2:
倒出master時加入參數直接打包壓縮
```
git archive --format tar.gz --output /full/path/to/zipfile.tgz master
```

沒有留言:

張貼留言