我的程序通常会生成很大的输出文件(~1 GB),我不希望将这些文件备份到git存储库。所以我们不能这样做
git add .
我必须做一些像这样的事情
git add *.c *.cc *.f *.F *.C *.h *.cu
有点麻烦..。
我相信我可以快速地将目录内容写入.gitignore中,然后删除基于.gitinclude (或类似名称)文件的文件,但这似乎有点过于老套了。有没有更好的方法?
发布于 2009-08-14 19:23:26
我自己并不需要尝试这个方法,但从我对TFM的阅读来看,一个被否定的模式似乎可以满足您的需要。您可以用稍后取消的条目覆盖.gitignore中的条目。因此,您可以这样做:
*.c
!frob_*.c
!custom.c
让它忽略除custom.c和任何以"frob_“开头的所有.c文件
发布于 2010-10-01 14:26:53
在您的存储库中创建.gitignore文件,并且您希望只跟踪c文件而忽略所有其他文件,然后向其中添加以下行...
*
!*.c
'*‘将忽略所有文件
还有!将否定文件是ignored....so这里我们要求git不要忽略c文件...
发布于 2020-04-01 11:52:49
如果您需要忽略文件,而不是目录中的特定文件,下面是我如何做到的:
# Ignore everything under "directory"
directory/*
# But don't ignore "another_directory"
!directory/another_directory
# But ignore everything under "another_directory"
directory/another_directory/*
# But don't ignore "file_to_be_staged.txt"
!directory/another_directory/file_to_be_staged.txt
https://stackoverflow.com/questions/1279533
复制相似问题