Git is ignoring .idea folder, but that isn't in gitignore

你说的曾经没有我的故事 提交于 2019-11-28 13:37:19

Do you have ~/.gitignore file? Here is the information that may be helpful.

Git has a very flexible hierarchy of ignore files: First it reads .gitignore file in your home directory. Put here common data for all repos (*.bak, for example, you definitely do not need them in any repo). Then, you can have .gitignore file in any folder inside your repo. It impacts on any files in this folder and its subdirectories. Also, you can have excludes in .git/info/exclude. It differs from .gitignore because it is not indexed, and you can put personal settings here. Of course ~/.gitignore is not indexed too.

I had the same problem. In my .git/exclude/info file, I exclude the names of executables that are created. But I often use the same name for the directories in which these executables reside, e.g. the "sphere" directory contains the executable "sphere". Since I had added all of the files before excluding the executable names in info/exclude, the fatal error never kicked in, even after excluding the directory/executable name to info/exclude.

Recently, however, I tried to add a file from a directory whose name was already excluded (because it matched the name of an executable I was excluding). The fatal error kicked in, and I was confused. I forced the add, and now any subsequent adds ignore the fatal error.

What this suggests is that it makes sense to exclude executable names in local .gitignore files, rather than in info/exclude.

If using the -f flag doesn't make any difference (i.e. the file still doesn't get staged), double check that the thing you're trying to add isn't already in the repository.

In my case I was trying to add something that had already been added and then deleted on a different branch, leading me to incorrectly think it had never been added in the first place. And Git was quite reasonably refusing to add the same thing twice.

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