.gitignore - extra command so it doesn't push to github?

I have node_modules inside my .gitignore but it's uploaded to github anyway, googling it point me to .gitignore but if i already have that... am i missing something?
24 Replies
ErickO
ErickO•2y ago
could be 2 things 1.- you are not setting it properly 2.- it was already included in a past commit before you had a gitignore if it's already in a commit then even if you add it to gitignore it keeps uploading it so you need to remove the file from git
CDL
CDL•2y ago
so the file existed before I ever typed git init, so it should have recognized it.. anyway, to remove it am I just to rm --node_modules?
ErickO
ErickO•2y ago
git rm --cached node_modules
CDL
CDL•2y ago
fatal: not removing 'node_modules' recursively without -r
ErickO
ErickO•2y ago
oh I always forget git rm -r --cached node_modules
CDL
CDL•2y ago
then is it a case of commiting and pushing without adding it? boom, yeah done 🙂
ErickO
ErickO•2y ago
no, gitiginore should work from now on, just double check that it is done correctly, I think it should just be node_modules/
CDL
CDL•2y ago
so inside .gitignore i have node_modules db.sqlite
ErickO
ErickO•2y ago
but yeah it was likely that you pushed it at some point before a gitignore and so you needed to remove from git cache it should be node_modules/ with the slash at the end idk if it makes a difference but at least for readability that tells me that is a folder
CDL
CDL•2y ago
makes sense, so if i were to git add . git commit and git push, it shouldn't push node_modules
ErickO
ErickO•2y ago
in theory, not anymore no you can check what is being added tho git status -s
CDL
CDL•2y ago
CDL
CDL•2y ago
that's what I get now i'll have to look into this one, as git add . is adding node_modules
ErickO
ErickO•2y ago
🤔 show your gitignore the .gitignore is in the same folder as node_modules yes?
CDL
CDL•2y ago
CDL
CDL•2y ago
it has to be something simple but because ive never done this (or havent in a year or 2), im not figuring it out 😄 until I figure it out ill just rm -r node_modules if i need to, but in future, is it as simple as git init -> git add -> git commit -> git push? as in, I go in, write some code, save it, then follow the above ^ and voila, it's on github as an updated file
ErickO
ErickO•2y ago
yes, well you do need to specify where it's going but whenever you make a new repo it'll tell you how to set it up after that you can just git add, commit, push
CDL
CDL•2y ago
do i have to specify that every time I open the file on a new day, for example? or should it already be registered to my github, so it's just a case of pushing any updates?
ErickO
ErickO•2y ago
once you git init and set the origin (github.com/blahblahblah.git) any future updates is just add,commit,push
CDL
CDL•2y ago
gotcha thanks for the help mate 🙂 I was genuinely losing my sanity haha
ErickO
ErickO•2y ago
np
CDL
CDL•2y ago
@erickohm .gitignore issue is because I created the gitignore file in cmd line on windows ,apparently saves it in the wrong UTF so deleted it, re-made it and it's now working 🙂
ErickO
ErickO•2y ago
Wtf Never would've guessed that Thanks Windows
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View