How to use conditions in gitignore

南楼画角 提交于 2019-12-02 11:36:21

Note that .gitignore only exists as a hint to git as to which files, directories or file types will be ignored by git add.

However, .gitignore will not stop any file to be added into repository if you use git add -f.

Long story short, .gitignore is rather simplistic mechanism that helps to avoid accidentally adding typical junk files (like editor backups, object files, executables, etc.), but it is not sophisticated enough to be capable of what you are asking for - like changing behaviour depending on some external conditions.

You can be careful not to add some files if you don't want them, or add ignored files with git add -f and thus overriding existing simple rules.

Alternatively, you can create some script and register it as git macro like git addc that will do such advanced filtering.

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