在用 git archive 打包时排除指定的文件(夹)

陪她去流浪 桃子 2016年05月13日 阅读次数:4227

git archive 命令默认在打包时会包含当前提交中所有的文件(不包含.git)。

然而很多时候并不是所有文件都需要打包,比如 .gitignore 文件就是典型。

可以通过把不需要的文件放到 .gitattributes 文件中使用 export-ignore 来排除掉这些不需要被打包的文件。

.gitignore        export-ignore
.gitattributes    export-ignore
/test             export-ignore

但要记得,这个文件要提交之后才会生效。

参考:

  1. Git - git-archive Documentation
  2. Excluding files from git archive exports using gitattributes

这篇文章的内容已被作者标记为“过时”/“需要更新”/“不具参考意义”。

标签:git