Netbeans和Git,.obj文件被忽略。

7
我正在进行一个涉及.obj文件的小型git项目。
当我查看“项目”选项卡时,我看到它们被忽略了。
但我不明白为什么,如果我查看我的.gitignore文件:
/DepthPeeling/nbproject/private/
/DepthPeeling/dist/
/DepthPeeling/build/

It looks fine

If I open a Git Bash and type

$ git add dragon.obj
The following paths are ignored by one of your .gitignore files:
DepthPelling/sry/depthPeeling/data/dragon.ogj
Use -f if you really want to add them.
fatal: no file added

什么?

可能有不止一个.gitignore文件吗?如果我寻找它们,我只能找到项目根目录中的一个(之前显示的那个),没有其他的了。

编辑:看起来我有一个全局忽略文件D:\Documents\gitignore_global.txt。

#ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.dll
*.lib
*.sbr

是的,每个目录中都可以有一个.gitignore文件,并且可以使用其他方式指定被忽略的文件。尝试使用find <repo> -name .gitignorecat <repo>/info/exclude命令。 - Biffen
你可以在你的项目中搜索其他 .gitignore 文件吗?从你的截图来看,似乎你正在使用 Windows 操作系统。 - Tim Biegeleisen
@TimBiegeleisen 我刚刚使用了Windows资源管理器。 - elect
1个回答

15

使用git check-ignore命令,可以轻易地找到忽略.obj文件的.gitignore规则:

git check-ignore -v -- dragon.obj

楼主报告:

"D:\\Documents\\gitignore_global.txt":5:*.obj –

这与此评论相似:

安装SourceTree(一种可视化git仓库的工具)后,它不合理地在文档文件夹下创建了一个名为gitignore_global.txt的文件,并将其中包含许多排除项。

git config -l应该显示类似以下内容:

[core] 
   excludesfile = C:\\Users\\username\\Documents\\gitignore_global.txt

1
哦天啊,你是对的,“D:\Documents\gitignore_global.txt”:5:*.obj。 - elect
@elect 看起来是源代码树安装:https://dev59.com/qGox5IYBdhLWcg3wGwlo#BqqgEYcBWogLw_1bCZSQ。我已经编辑了答案。 - VonC
无论如何,提交现在已经看到它们了,我现在正在上传它们,谢谢! - elect

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接