git - 要求在 GitHub 中推送被忽略的文件
问题描述
我在 GitHub.com 中有存储库。对于推拉,我使用了一个可视化工具 Github Desktop。最近我在 Github.com 上创建了一个存储库来存储 .NET Core API 项目。我创建了一个 git ignore 文件,指示哪些文件不应提示推送。git忽略文件如下:
Source/.vs/*
Source/Libraries/Common/bin/*
Source/Libraries/Common/obj/*
Source/Libraries/Data/bin/*
Source/Libraries/Data/obj/*
Source/Libraries/Domains/bin/*
Source/Libraries/Domains/obj/*
Source/Libraries/Services/bin/*
Source/Libraries/Services/obj/*
但是每次我在 Visual Studio 2019 中构建项目时,以下文件都会提示推送,尽管它们包含在 git ignore 中不提示。提示的文件列表如下:
Source/Libraries/Common/bin/Debug/netcoreapp3.1/Common.dll
Source/Libraries/Common/bin/Debug/netcoreapp3.1/Common.dll
Source/Libraries/Common/bin/Debug/netcoreapp3.1/Common.pdb
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.csproj.FileListAbsolute.txt
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.csprojAssemblyReference.cache
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.dll
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.pdb
Source/Libraries/Data/bin/Debug/netcoreapp3.1/Data.dll
Source/Libraries/Data/bin/Debug/netcoreapp3.1/Data.pdb
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.csproj.FileListAbsolute.txt
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.csprojAssemblyReference.cache
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.dll
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.pdb
Source/Libraries/Domains/obj/Debug/netcoreapp3.1/Domains.csproj.FileListAbsolute.txt
Source/Libraries/Domains/obj/Debug/netcoreapp3.1/Domains.csprojAssemblyReference.cache
Source/Libraries/Services/obj/Debug/netcoreapp3.1/Services.csproj.FileListAbsolute.txt
Source/Libraries/Services/obj/Debug/netcoreapp3.1/Services.csprojAssemblyReference.cache
Source/Web/obj/Debug/netcoreapp3.1/Web.csproj.FileListAbsolute.txt
Source/Web/obj/Debug/netcoreapp3.1/Web.csprojAssemblyReference.cache
Source/.vs/CashFlow/v16/.suo
Source/.vs/CashFlow/v16/.suo
Source/Libraries/Common/bin/Debug/netcoreapp3.1/Common.dll
Source/Libraries/Common/bin/Debug/netcoreapp3.1/Common.pdb
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.csproj.FileListAbsolute.txt
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.csprojAssemblyReference.cache
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.dll
Source/Libraries/Common/obj/Debug/netcoreapp3.1/Common.pdb
Source/Libraries/Data/bin/Debug/netcoreapp3.1/Data.dll
Source/Libraries/Data/bin/Debug/netcoreapp3.1/Data.pdb
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.csproj.FileListAbsolute.txt
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.csprojAssemblyReference.cache
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.dll
Source/Libraries/Data/obj/Debug/netcoreapp3.1/Data.pdb
Source/Libraries/Domains/obj/Debug/netcoreapp3.1/Domains.csproj.FileListAbsolute.txt
Source/Libraries/Domains/obj/Debug/netcoreapp3.1/Domains.csprojAssemblyReference.cache
Source/Libraries/Services/obj/Debug/netcoreapp3.1/Services.csproj.FileListAbsolute.txt
Source/Libraries/Services/obj/Debug/netcoreapp3.1/Services.csprojAssemblyReference.cache
Source/Web/obj/Debug/netcoreapp3.1/Web.csprojAssemblyReference.cache
谁能帮我解决这个问题。
解决方案
您尚未添加所有子目录。例如,您的 .gitignore 应该如下所示。
Source/.vs/*
Source/Libraries/Common/bin/*
Source/Libraries/Common/obj/*
Source/Libraries/Data/bin/*
Source/Libraries/Data/obj/*
Source/Libraries/Domains/bin/*
Source/Libraries/Domains/obj/*
Source/Libraries/Services/bin/*
Source/Libraries/Services/obj/*
# new lines:
Source/Libraries/Common/bin/Debug/*
Source/Libraries/Common/bin/Debug/netcoreapp3.1/*
Source/Libraries/Common/obj/Debug/*
Source/Libraries/Common/obj/Debug/netcoreapp3.1/*
Source/Libraries/Data/bin/Debug/*
Source/Libraries/Data/bin/Debug/netcoreapp3.1/*
并添加构建显示它正在添加的所有其他文件夹,而不是像我开始做的那样添加文件。使用星号添加所有内容不会添加子目录。
推荐阅读
- flutter - 一种在颤振中将字符串读取为飞镖代码的方法?
- python - 如何将站名(文本)从 csv 文件绘制到地图
- c# - 如何获取目录中的所有文件以跳过未经授权的文件?
- suricata - SQLI 的 Suricata 规则
- php - SQLSTATE [42S22]:找不到列:1054 未知列 - Laravel Livewire 购物车
- php - 400 错误请求
- python - 如何使用 30 系列卡加速 tensorflow 中的“添加可见 gpu 设备”过程?
- docker - 如何在 Docker 中链接 PostgreSQL 容器和 PgAdmin?
- ssl - Debian 9 Tomcat 9 让我们加密 SSL 配置
- javascript - new Date() 与 Utilities.formatDate(new Date())