为什么git查找我的主目录中不存在的目录?

时间:2019-08-08 17:59:11

标签: git directory gitignore ignore

我正在Windows 10上的主目录中运行git存储库。当我运行git status时,Git会找到我的机器上不存在的目录:

warning: could not open directory 'AppData/Local/Application Data/': Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Low/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permission denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Documents/My Music/': Permission denied
warning: could not open directory 'Documents/My Pictures/': Permission denied
warning: could not open directory 'Documents/My Videos/': Permission denied
warning: could not open directory 'Local Settings/': Permission denied
On branch master
Your branch is up to date with 'origin/master'.

上面的许多目录不存在。为什么Git试图打开这些 不存在 目录?

我的.gitignore:

#===============================================================================
# Blacklist everything, then whitelist sub-directories
#===============================================================================
# this allows me to whitelist individual FILES in sub-directories
*
!*/


#===============================================================================
# WHITELIST SPECIFIC THINGS
#===============================================================================
!.gitignore
!.bashrc
!.alias.sh
!.update.home.sh
!.startup.sh
!.todo
!dictionary.txt
!./.config/git/gitk
!Documents/ShareX/ApplicationConfig.json

1 个答案:

答案 0 :(得分:2)

  

可选的前缀“!”否定了模式;先前模式排除的所有匹配文件都将再次包含在内。

摘自gitignore文档。

因此,如果我正确地理解了这一点,您的行!*/(黑名单区域的第二行)将重新包含主目录中的所有目录,显然包括上述所有目录。

要显示主目录中的所有内容(以及 hidden 目录),请打开命令提示符"Win" + "R",键入cmd并单击"Enter"。输入 dir /a,点击"Enter",您会看到所有想知道的 do 目录都显示在您的主目录中。