git - 为什么 git 会找到我的主目录中不存在的目录?

标签 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

最佳答案

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/

相关文章:

linux - 使用 ssh 连接时 git clone 失败

git - "inverse"的 `git rebase <some-branch>` 怎么办?

Git 命令执行 pull 并将我的更改放在顶部而不 stash ?

c# - 循环文件夹的文件并添加为附件

git - 忽略已经提交到 Git 存储库的文件

git - 取消忽略特定的 bin 目录

python - 我应该在 pip 的需求文件中输入什么来选择正确的 git 分支?

eclipse - 如何用Java创建Eclipse文件夹资源过滤器

c - 当内存可用时 Realloc() 返回 NULL - C

git - 强制 git 更新 .gitignore