Make .gitignore ignore everything except a few files

前端 未结 23 2903
无人共我
无人共我 2020-11-22 00:14

I understand that a .gitignore file cloaks specified files from Git\'s version control. I have a project (LaTeX) that generates lots of extra files (.auth, .dvi, .pdf, logs,

23条回答
  •  醉梦人生
    2020-11-22 00:50

    An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.

    # 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/*
    

提交回复
热议问题