问题描述
我知道一个.gitignore文件隐藏了Git版本
控件中的指定文件。我有一个项目(LaTeX)在运行时会生成大量额外的文件(.auth,
.dvi,.pdf,日志等),但我不希望跟踪这些文件。
我知道我可以(也许应该)制作它,这样所有这些文件都放在项目中的
单独的子文件夹中,因为我可以忽略该文件夹。
然而,是否有任何可行的方法将输出文件保存在
项目树的根目录中,并使用.gitignore忽略除文件I之外的所有内容'm
用Git跟踪?就像
#忽略所有内容
*
#但不是这些文件...
script.pl
template.latex
#etc ...
#忽略所有内容
*
#但不是这些文件...
!.gitignore
!script.pl
!template.latex
#etc ...
#...即使它们在子目录中
!* /
#如果文件被跟踪的是子目录
!* / a / b / file1.txt
!* / a / b / c / *
I understand that a .gitignore file cloaks specified files from Git's versioncontrol. 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.
I'm aware that I could (maybe should) make it so all those files are put in anseparate 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 theproject tree and use .gitignore to ignore everything except the files I'mtracking with Git? Something like
# Ignore everything
*
# But not these files...
script.pl
template.latex
# etc...
# Ignore everything
*
# But not these files...
!.gitignore
!script.pl
!template.latex
# etc...
# ...even if they are in subdirectories
!*/
# if the files to be tracked are in subdirectories
!*/a/b/file1.txt
!*/a/b/c/*
这篇关于让.gitignore忽略除几个文件以外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!