我正在 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
最佳答案
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.
来自gitignore文档。
因此,如果我正确理解,您的行 !*/
(黑名单区域中的第二行)将重新包含主目录中的所有目录,显然包括上述所有目录。
要显示主目录中的所有内容(以及 stash 目录),请打开命令提示符“Win”+“R”
,输入cmd
并点击“Enter”
。进入
dir/a
,按“Enter”
,您将看到您想知道的所有目录do都显示在您的主目录中。
关于git - 为什么 git 会找到我的主目录中不存在的目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57418326/