Gitignore everything except a subfolder (with every content)?

后端 未结 3 581
感动是毒
感动是毒 2020-12-03 20:06

I want to ignore everything, except a specific subfolder (and all of its contents!). I tried solutions from possible duplicate questions without any success.

I\'d ne

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 20:58

    I want to ignore everything

    add the folder to the gitignore

    except a specific subfolder (and all of its contents!).

    force folder to be added to the repository

    git add -f folder
    

    EDIT:

    I use this solution for example when I need to keep log folder, for example, but not its content. Generally, when I suppose the content of the folder is never to be added. And generally I add just path/to/folder/.gitkeep file with -f option.

提交回复
热议问题