.gitignore ignore all files then recursively allow *.foo

后端 未结 1 1237
广开言路
广开言路 2020-11-27 11:54

There\'s already several questions similar to this, but none of the answers work for me.

I want to ignore everything in the folders below my repository except files

相关标签:
1条回答
  • 2020-11-27 12:54

    Your problem is that the /* pattern at the beginning is matching all files and directories at the top level - including testdir, so everything inside testdir is ignored.

    This is what you want:

    # Ignore everything
    *
    # Don't ignore directories, so we can recurse into them
    !*/
    # Don't ignore .gitignore and *.foo files
    !.gitignore
    !*.foo
    

    When you do a git add . with this config, you should find you have only .gitignore and *.foo files listed as changes to be committed.

    0 讨论(0)
提交回复
热议问题