GitExtensions 不尊重 .gitignore

GitExtensions not respecting .gitignore

我正在使用 Windows 10 64 位和 Git 扩展 2.51.01

我已将 https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 中的 .gitignore 文件添加到 [=] 根目录中的 .gitignore 文件夹中30=] 个存储库,包括

[Bb]in/
[Oo]bj/

并且 git 扩展的提交对话框显示了太多文件,包括 bin 和 obj 文件夹中的许多文件。我没有激活 "Show Ignored files" 选项。

这些是尚未添加到存储库的文件,它们旁边有 + 图标。

如果我使用 Git Extensions 的 "add to gitignore" 右键单击​​选项然后输入 bin/ 并单击 "Ignore" 我会出现以下错误:

System.UnauthorizedAccessException: Access to the path ... is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
at
GitUI.CommandsDialogs.FormAddToGitIgnore.<>c__DisplayClass8_0.<AddToIgnoreClick>b__0(String x)
at
GitUI.CommandsDialogs.FormAddToGitIgnore.AddToIgnoreClick(Object sender, EventArgs e)

.gitignore 必须是文件,不是文件夹。 https://github.com/github/gitignore 中的自述文件实际上是这么说的。 我相信您将文件从该存储库复制到您的存储库并将其重命名为 .gitignore。在 Windows 资源管理器中,您将其重命名为 .gitignore.(注意结尾的点)。

您可以在 https://git-scm.com/docs/gitignore 或 google.

找到详细信息