.gitignore 不阻止目录被推送到 github

.gitignore not preventing a directory being pushed to github

我正在构建一个 React Native 应用程序,我不想在其中将 android 和 ios 目录推送到 github。无论我在 .gitignore 文件中写什么,这两个目录总是被推送到 github。以下是我在 .gitignore:

中使用的模式
1. android 
   ios
2. /android/*
   /ios/*
3. android/
   ios/
4. /android
   /ios

请告诉我如何防止这些文件夹进入 github?

谢谢!!

伙计们,编号和缩进不是真的。我用它们只是为了描述我尝试了多少种方法。

首先,您必须将这些行添加到 .gitignore

android/
ios/

然后按照以下答案取消跟踪提交的文件夹:

Ignore files that have already been committed to a Git repository