4

I have this .gitignore file in my android project but does not apply to the .cxx folder. I tested everything but failed.

.cxx
app/.cxx
app/.cxx/

Android Studio

enter image description here

We had trouble working with my colleagues on this project as they changed .cxx files each time the project was build.

How can i fix this problem ?

Mohammad ZF
  • 113
  • 1
  • 10
  • 2
    Does this answer your question? [How to make Git "forget" about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – EncryptedWatermelon Oct 30 '19 at 14:47

3 Answers3

9

Option 1:

I'm guessing this folder has been checked into git before?

Run git rm -r --cached <folder> and check again.

Option 2:

For me, the accepted answer was part of the solution, not the entire solution. Maybe, the other steps that I'm about to post were obvious, but I missed them first. Here's the steps I took to ensure my .gitignore file ignored the folder I wanted it to ignore:

  1. Commit any changes that you need to fix/change.
  2. Run this command: git rm -r --cached . (which removes everything from the git index in order to refresh your git repository)
  3. Then run this command: git add . (to add everything back to the repo)
  4. Finally, commit these changes using git commit -m ".gitignore Fixed"

You can find the link to the article from where I found the solution https://digitizor.com/gitignore-not-ignoring-files-how-to-fix/

S_i_l_e_n_t C_o_d_e_r
  • 2,179
  • 2
  • 7
  • 21
4

I would try something like:

*.cxx
app/.cxx/*

And before that make sure these files are not already tracked by git, once the file is in, .gitignore does not do anything for that file.

lenik
  • 22,629
  • 4
  • 31
  • 41
1
git rm --cached -r .
git add .

This command will ignore the files that have already been committed to a Git repository but now we have added them to .gitignore.

Srinivas
  • 21
  • 6