问题:
I understand that a .gitignore file cloaks specified files from Git's version control. 我知道.gitignore文件会掩盖Git版本控制中的指定文件。 I have a project (LaTeX) that generates lots of extra files (.auth, .dvi, .pdf, logs, etc) as it runs, but I don't want those to be tracked. 我有一个项目(LaTeX),它在运行时会生成许多其他文件(.auth,.dvi,.pdf,日志等),但我不希望这些文件被跟踪。
I'm aware that I could (maybe should) make it so all those files are put in an separate subfolder in the project, since I could then just ignore the folder. 我知道我可以(也许应该这样做)将所有这些文件放在项目的单独子文件夹中,因为这样我就可以忽略该文件夹了。
However, is there any feasible way to keep the output files in the root of the project tree and use .gitignore to ignore everything except the files I'm tracking with Git? 但是,是否有任何可行的方法将输出文件保留在项目树的根目录中,并使用.gitignore忽略除我正在使用Git跟踪的文件以外的所有内容? Something like 就像是
# Ignore everything
*
# But not these files...
script.pl
template.latex
# etc...
 
解决方案:
参考一: https://stackoom.com/question/48ne/使-gitignore忽略除少数文件以外的所有内容参考二: https://oldbug.net/q/48ne/Make-gitignore-ignore-everything-except-a-few-files
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4478784