问题描述
我的程序通常会生成大量的输出文件(〜1 GB),我不想备份到git存储库。所以,而不是能够做到/ b
My programs generally generate huge output files (~1 GB) which I do not want to be backing up to the git repository. So instead of being able to do
git add .
我必须做一些类似于
git add *.c *.cc *.f *.F *.C *.h *.cu
这有点烦琐...
我觉得我可以写一个快速的perl脚本,到.gitignore,然后删除基于.gitinclude(或一些类似的名称)文件的文件,但这似乎有点过于黑客。有没有更好的方法?
I feel fairly confident I could write a quicky perl script ls the directory contents into .gitignore and then remove files based on a .gitinclude (or some similar name) file, but that seems a little too hackish. Is there a better way?
推荐答案
我没有必要自己尝试这个,但是从我阅读它看起来像一个否定模式会做你想做的事。您可以使用稍后取消的条目覆盖.gitignore中的条目。因此,您可以执行以下操作:
I haven't had need to try this myself, but from my reading of TFM it looks like a negated pattern would do what you want. You can override entries in .gitignore with later negated entries. Thus you could do something like:
*.c
!frob_*.c
!custom.c
让它忽略除custom.c之外的所有.c文件以及任何以frob _开头的文件
To have it ignore all .c files except custom.c and anything starting with "frob_"
这篇关于有没有办法告诉git只包含某些文件而不是忽略某些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!