0

I created a simple community app using firebase as an exercise using the create-react-app command.

At this time, firebase.js is created and stored here for things related to firebase security, and firebase.js is imported from App.js where the main page is located.

The reason I made firebase.js separately is that I tried to ignore firebase.js with gitignore because I was trying to upload the project to GitHub, but it would be dangerous if important information was leaked.

I added /src/firebase.js to .gitignore, but firebase.js was still visible in the GitHub repository.

TLDR

I entered /src/firebase.js in gitignore, but firebase.js was still showing up.

A-Tech
  • 806
  • 6
  • 22
Songkail
  • 27
  • 2
  • 5
    `.gitignore` only affect files that are _not_ tracked. If the file is tracked, you need to remove it... at least from git, that is. I would be willing to bet that some 50% of questions related to `.gitignore` not working deal with this situation and there are plenty of answers on how to deal with it. – eftshift0 Apr 03 '23 at 15:46
  • 1
    Does this answer your question? [How do I make Git forget about a file that was tracked, but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-do-i-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – picobit Apr 07 '23 at 17:21

1 Answers1

1

.gitignore only ignores specified untracked files; any untracked file listed in .gitignore will never be tracked. It does not retroactively remove already-tracked files from Git. (This is mentioned a few times in the gitignore documentation.)

The catchier version of that last paragraph: it's .gitignore, not .gitforget.

If you'd like Git to stop tracking a file, then use git rm --cached.

Jim Redmond
  • 4,139
  • 1
  • 14
  • 18
  • I've added /src/firebase.js to gitignore, but I'd like to ask you about /src/firebase.js still being seen on the github page. – Songkail Apr 04 '23 at 13:19
  • It's still on the GitHub page because it's still in the repo. You need to run the remove command, then commit and push. – Jim Redmond Apr 04 '23 at 17:17