Make .gitignore ignore everything except a few files

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

    The simplest way that I go about this is to force add a file. It will be accounted for in git even if it is buried or nested inside a git-ignored subdirectory tree.

    For example:

    x64 folder is excluded in .gitignore:

    x64/
    

    But you want to include the file myFile.py located in x64/Release/ directory. Then you have to:

    git add -f x64/Release/myFile.py
    

    You can do this for multiple files of files that match a pattern e.g.

    git add -f x64/Release/myFile*.py
    

    and so on.

提交回复
热议问题