Can you have additional .gitignore per directory within a single repo?

二次信任 提交于 2019-11-30 10:32:18

问题


Can you create a .gitignore file in a directory that only applies to files (and directories) within that directory?


回答1:


Yes, you can. Try it, it works fine. Put a .gitignore in the root of your repo, and put another .gitignore with additional things to ignore in a subdirectory.




回答2:


Similar question was: Are multiple `.gitignore`s frowned on? (Jul 2010)

Or if you can have different version of a .gitignore file per branch: Using github to host public git repositories whilst ensuring that sensitive data files remain untracked (Feb 2010)

Further perhaps related: How do I tell git to always select my local version for conflicted merges on a specific file?




回答3:


You can just specify files to ignore in a format such as

Xyz/*.abc

in the .gitignore in the root directory, potentially removing the need for separate ignore files.



来源:https://stackoverflow.com/questions/9730486/can-you-have-additional-gitignore-per-directory-within-a-single-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!