0

I made a small replication game called Snake, and it uses a small json database through node express. And right now, I deployed the game to Heroku using git. However, whenever I change index.js or index.html in my public path, and after commit them and git push origin master, it pushes every single file I have in my project. Including all node modules and my json database. There were people's saved scrores on my online json file, but after pushing my index.js, the online json cleared it's content.

So is there any way to only push the commited files? I tried other's solution like to make a new branch and checkout or something but it doesn't work for me. When I created a new branch and checkouted my paths, it tells me I have a bunch of files needed to commit.

Also, when I push everytime, it takes a long time to upload because it is uploading all the node modules everytime.

Hitoki
  • 15
  • 1
  • 4
  • 2
    Possible duplicate of [How to ignore certain files in git?](https://stackoverflow.com/questions/4308610/how-to-ignore-certain-files-in-git) – Virginia Dec 16 '18 at 18:04

2 Answers2

0

What you are looking for is Git Ignore. It's a way to exclude certain files from being commited. As you pointed out, in NodeJS, it's a good practice to exclude the node_modules.

There's a project named gitignore.io, which helps you craft proper .gitignore files, with common patterns.

Now that you already commited your node_module, you will have to delete the commited files with:

git rm -r --cached node_modules
aadlani
  • 601
  • 5
  • 18
0

git push only pushes committed file. What you want should be use ignore file to ignore unnecessary file in latest commit.

check git ignore for how to use ignore file.

feedfood
  • 95
  • 3