Reputation: 2947
I finished step 1 in this tutorial on how to set up a MERN stack project.
I have a .gitignore
with the following contents
/backend/node_modules
/backend/package-lock.json
However, when I git push
, node_modules
and package-lock.json
get added to my respository as seen here
How can I remove node_modules
and package-lock.json
from my github repository and in future commits?
Upvotes: 1
Views: 115
Reputation: 2947
I made a very dumb mistake of setting my git remote add origin in my backend folder and not my root folder. Deleted the project, started again and made sure to to git remote add origin in root and my gitignore behaves as expected.
Upvotes: 0
Reputation: 159
When I compare with my git ignore, there is no / in the beginning of the folder names. You should look at that. To me it means absolute path. You should also use git status to check what can be staged before committing anything. If your node_module is properly ignored by GIT, it will not appear in Git Status.
To remove on Github you should try this
git rm --cached node_modules package-lock.json
git commit -m "Your message here."
git push -u origin master
Tested this at the moment and it works. my files are still on the local drive but removed from remote repository. Best Regards.
Upvotes: 1
Reputation: 1324208
If your repository is in the backend folder, meaning you have
backend
.git
Then your .gitignore should be:
/node_modules
/package-lock.json
You can:
git rm --cached
those two elementsUpvotes: 1