.gitignore 目录上的 git 警告“无法访问权限被拒绝”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25137925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:16:38  来源:igfitidea点击:

git warning "unable to access permission denied" on a .gitignore directory

gitgitignore

提问by Parth Shah

I have a sub-directory called ".gitignore" in one of my directories called "Database", which I want git to ignore, so I listed it in my .gitingore file.

我在名为“Database”的目录之一中有一个名为“.gitignore”的子目录,我希望 git 忽略它,所以我将它列在我的 .gitingore 文件中。

.gitignore:

.gitignore:

    [Bb]in/
    [Dd]ebug/
    [Rr]elease/
    .gitignore/

When I perform a command like git status Database, i get the following warning:

当我执行像 git status Database 这样的命令时,我收到以下警告:

warning: unable to access 'Database/.gitignore': Permission denied

Can anyone please help me understand what I can do to get rid of this warning?

任何人都可以帮助我了解我可以做些什么来摆脱这个警告?

PS: I verified folder permissions on both "Database" and ".gitingore" were the same.

PS:我验证了“数据库”和“.gitingore”的文件夹权限相同。

PS: I am running git on Windows 8. I don't think this matters.

PS:我在 Windows 8 上运行 git。我认为这并不重要。

回答by MichaelJones

I'm not sure what you're experiencing but I would imagine that having a foldercalled .gitignoreis a bad idea. Git might be trying to open it and read it like a file as it needs to know the contents of .gitignorefiles.

我不确定您正在经历什么,但我认为拥有一个名为的文件夹.gitignore是一个坏主意。Git 可能会尝试打开它并像读取文件一样读取它,因为它需要知道.gitignore文件的内容。

Try calling it something else and then adding its name to a .gitignorefile next to it in the directory.

尝试将其命名为其他名称,然后将其名称添加到.gitignore目录中它旁边的文件中。

回答by iBug

Copy your .gitignore file and paste it on your desktop. Then open it and make changes. Delete previous file in your folder and paste updated one.

复制您的 .gitignore 文件并将其粘贴到您的桌面上。然后打开它并进行更改。删除文件夹中的上一个文件并粘贴更新的文件。

Hidden files cannot be replaced or edited.

无法替换或编辑隐藏文件。