0

I am trying hide this file .netlify/state.json by adding it to my git but it still shows in my github repo. I just want to hide the state.json file somehow.

My .gitignore file is in my root directory. The .netlify folder is in my root directory.

I have already tried adding several variations of the directory to the .gitignore file.

.netlify/state.json

state.json

.netlify

../.netlify

.netlify/state.json

but it still none of them worked.

Here is the link to my github repo:

https://github.com/able-leopard/a-day-in-the-life-on-mars

Thank you very much in advance!

phd
  • 82,685
  • 13
  • 120
  • 165
able-leopard
  • 115
  • 1
  • 14
  • Possible duplicate of [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) – phd Sep 01 '19 at 12:02

2 Answers2

2

This is probably caused by a previous commit, if you already have a commit containing that file you will only be ignoring new changes to that file, so you have two options here: delete the file completely or remove it from your source control.

If you want to completely delete the file you could run git rm .netlify/state.json

If you only want to prevent git from tracking that file but not delete it you'll need to run git rm --cached .netlify/state.json

Just remember to add the correct path to that file in the .gitignore file to stop tracking it.

Dimitri Acosta
  • 1,756
  • 12
  • 15
1

Once you have added a file and committed it to git, adding it to .gitignore will only ignore changes made to the file.

If you want to remove it from your repository, then run: git rm .netlifly/state.json

This will remove it from the index and ultimately delete it from the repository. It will NOT remove it from your directory.

Walter
  • 21
  • 1
  • 8