Search code examples
gitgithubgitignore

.gitignore not preventing a directory being pushed to github


I am building a react native application in which I don't want to push android and ios directories to github. No matter what I am writing in .gitignore file, these two directories are always being pushed to the github. Following are the patterns that I have used in .gitignore:

1. android 
   ios
2. /android/*
   /ios/*
3. android/
   ios/
4. /android
   /ios

Please tell me how can I prevent these folders from going to github?

Thanks!!

Guys the numbering and indentation is not real. I have used them just to depict how many ways I have tried.


Solution

  • First, you have to add these lines to .gitignore

    android/
    ios/
    

    Then follow the answer below to untrack committed folders:

    Ignore files that have already been committed to a Git repository