Make .gitignore ignore everything except a few files

前端 未结 23 2615
无人共我
无人共我 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

    I seem to have found something that worked for me which no one else mentioned.

    # Ignore everything
    *
    
    # But not these files...
    !.gitignore
    !script.pl
    !template.latex
    # etc...
    
    # And if you want to include a sub-directory and all sub-directory and files under it, but not all sub-directories
    !subdir/
    !subdir/**/*
    

    Basically, it seems to negate a sub-directory from being ignored, you have to have two entries, one for the sub-directory itself !subdir/ and then another one which expands to all files and folders under it !subdir/**/*

提交回复
热议问题