0

I don't understand why git in pycharm keeps tracking my .gitignore file despite .gitignore is in the file itself

The same issue with .env file in the root of the project

How can i solve this issue?enter image description here

Andrejs Cainikovs
  • 27,428
  • 2
  • 75
  • 95
Faenno
  • 27
  • 8
  • You don't keep `.gitignore` in `.gitignore`. Second, if this is specific to PyCharm - this is offtopic. – Andrejs Cainikovs Mar 01 '23 at 20:18
  • @AndrejsCainikovs this happens with every file in the project root, not just .gitignore. I tried the same with .env and just text file "test.txt" - I created these files, added them to .gitignore but git keeps tracking them. And also I didn't understand why you removed "pycharm" tag, it can be specific to pycharm, no? – Faenno Mar 01 '23 at 20:23
  • When you created those files, did pycharm ask if you wanted to add them to version control? and did you choose yes? Generally if a file is already being tracked by git, putting them in .gitignore isn't going to make git ignore them. – jingx Mar 02 '23 at 03:47

1 Answers1

0

Try the following commands:

  1. git rm -r --cached .
  2. git add .
  3. git commit -m "Gitignore issue fixed".

refer this for more detailed description: Why isn't my updated .gitignore working for files that are being tracked?

Nitesh
  • 60
  • 7