Make .gitignore ignore everything except a few files

前端 未结 23 2621
无人共我
无人共我 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 01:04

    This is how I did it:

    # Ignore everything
    *
    
    # Whitelist anything that's a directory
    !*/
    
    # Whitelist some files
    !.gitignore
    
    # Whitelist this folder and everything inside of it
    !wordpress/wp-content/themes/my-theme/**
    
    # Ignore this folder inside that folder
    wordpress/wp-content/themes/my-theme/node_modules
    
    # Ignore this file recursively
    **/.DS_Store
    

    Use gig status -u to view individual files in untracked directories recursively - with git status you'd only see folders, which could fool you into thinking that everything inside them was tracked

提交回复
热议问题