Gitignore files and folders isn't working as wished

Viewed 32

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

1 Answers

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
Related