Git Won't Un-Ignore a Directory

前端 未结 5 1937
星月不相逢
星月不相逢 2020-12-31 08:26

I\'d like to only track certain directories in git in a larger project, where most directories will be excluded and only a few will be tracked. So, I wanted to use

5条回答
  •  生来不讨喜
    2020-12-31 09:07

    Don't mention the directories in your .gitignore, just the files. Doing this and explicitly adding the directories you want to track should give you what you want:

    $ cat > .gitignore << EOF
    *
    !bar
    EOF
    $ git add -f iwantthesefiles
    

    This will let git track bar and everything in the directory iwanthesefiles.

提交回复
热议问题