gitignore not ignoring file gitignore not ignoring file xcode xcode

gitignore not ignoring file


You can only ignore unversioned files but that file is already known to git.

If you want git to track that file, there is no need to tell git to ignore it.

If you don't want git to track that file use git rm and your ignore rule will start working.

Caution: git rm will remove the file. Use git rm --cached to remove from the repo but not from the disk.


I had same problem.

First commit any outstanding code changes, and then, run this command:

git rm -r --cached .

This removes any changed files from the index(staging area), then just run:

git add .

Commit it:

git commit -m ".gitignore working now"

To undo git rm --cached filename, use git add filename.


One of the easy ways to ignore files on GitHub is perfectly explained herehttps://help.github.com/en/articles/ignoring-files

Before you do any push to GitHub, your project folder should be blank.

1) open terminal and write cd

and drag your project folder over terminal. After that it will look like this:

docmacbook$ cd /Users/docmacbook/Downloads/MyProjectFolder

2) Open .gitignore file and add files you want to ignore. For example my .gitignore file looks like this:

MyAppName.xcodeproj/xcuserdataMyAppName.xcworkspace/xcuserdataPodsreport.xml

3) Commit and Push to GitHub.

After this move your project or create a new one in the folder where .gitignore file is and now files you want to be ignored will not be pushed to your GitHub.

Note: These steps will work for an existing project too I think, did not tested.