git - 如何防止 .idea/ 目录被推送到远程?
问题描述
新手到 git 工作流程。
我已经开始从事一个开源项目。我分叉了回购。
但是,当我将提交推送到远程分叉时,.idea/
会在 GitHub 上生成一个目录。Github 回购。我的 gitignore 文件包含.idea/
路径。
我已在此Remove a file from a Git repository./idea
的帮助下删除了本地 git 存储库。但是,当我推送到远程时,目录仍然存在。.idea/
解决方案
我的 gitignore 文件包含 .idea/ 路径。
一旦您提交文件,它将开始被跟踪。所以将它添加到您的 中是不够的.gitignore
,您还必须将其从存储库中删除。
为了从此时删除文件,您必须从存储库中删除它们。
git rm --cached .idea/
此命令仅从暂存中删除文件,而不是从文件系统中删除,稍后添加到 .gitignore。
您现在需要做的是删除整个 .idea 文件夹,提交删除,将想法扩展名添加到您的 .gitignore 文件中。
# Remove the file from the repository
git rm --cached .idea/
# now update your gitignore file to ignore this folder
echo '.idea' >> .gitignore
# add the .gitignore file
git add .gitignore
git commit -m "Removed .idea files"
git push origin <branch>
推荐阅读
- android-camera2 - 使用 MediaCodec 将视频帧 RGB 编码为 YUV_420_888 | Android Camera2 API
- matlab - 如何将所有子文件夹和文件添加到linux中的matlab路径
- jspdf - 我可以导入现有的 pdf 文件以使用 jsPdf 进行修改吗?
- mysql - 与其他表交叉不同的列值
- java - 在 Java 中,应用数学函数时会丢失准确性
- docker - Kubernetes 中容器状态的所有原因列表
- python - %1 不是有效的 Win32 应用程序(lnk 文件)
- c# - 如何在加载时淡出和破坏音频
- c# - 在 ASP.NET Core 3.0 中替换 ExpressionHelper?
- node.js - 如何提高 nodejs lambda 性能