0

I am new to git and I want to choose which files I want to push. Some files are private for private purposes obviously so I dont want git to track them. I created a .gitignore file and I added which folder and files I dont want to be tracked. So in this case I dont want the Classes folder to be tracked and I dont want the settings.json file to be tracked either. So I saved the .gitignore file and did

git add .
git commit -m "test"
git push origin master

but every single file still got pushed into my rep on github

Also as you could see the Class folder is still connected to my git rep because everytime I do a change for instance the file in the folder turns orange as you could see on main.cpp

Here is how it looks like

Kevin R
  • 25
  • 3
  • Could you also provide the contents of your `.gitignore` file? Most likely the configuration of the file is not correct. – matthlud Sep 08 '22 at 21:53
  • The contents of my .gitignore file is in the image that I posted. But here it is: C++/.vscode/settings.json C++/Classes – Kevin R Sep 08 '22 at 22:07
  • No images of code/text allowed. – matt Sep 08 '22 at 22:24
  • 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) – 1615903 Sep 09 '22 at 03:40

1 Answers1

0

If your .gitignore is already in the C++ folder, then its rules should not start with C++/...

Once you edit your .gitignore to remove the leading C++/, make sure your files were not already added to the index and/or committed: that would not be ignored anyway.

Check your .gitignore is working with git check-ignore:

git check-ignore -v -- a/file/which/should/be/ignored
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250