What files can or should not be put into GitHub when you build your app?

Hello, since this is going to be my first time putting something into GitHub when building something with React to share to others... what files do I put? When I was only using html, css, and javascript it was very easy as I just put everything into the folder and BAM, it's in gitHub and working fine. Now that I'm using React, theres a node_modules, public, src, and build folders. There is also a package-lock, and package json files. There is so much other folders and files that I don't know which of theses of should I put into a folder so that publish into GitHub like, do I just put everything from the folder into github or do I only put the build folder? I'm kind of confused about that. Thanks in advance 🙂
5 Replies
b1mind
b1mind2y ago
Do not include your node_modules that should always be in your .gitignore you wont need any build folders either if you are also wanting to host it there* you would ig but look into how gitHub pages works cause typically it will require extra steps to set up by default it uses like a docs folder
kingtigerknight
kingtigerknightOP2y ago
Ahhh ok. Thanks 🙂
Jochem
Jochem2y ago
There's also a useful collection of gitignore files here https://github.com/github/gitignore and most framework base projects at least should come with a sensible .gitignore
WebMechanic
WebMechanic2y ago
avoid binary files such as content/placeholder images, once in the repo, always in the repo, and they may cause massive cumulated downloads if they're not "properly" deleted from Git's history. also watch out for commercial font files (copyright issues). needless to say: config files and test fixtures with credentials incl. .env files -- however they're usually part of most gitignore templates Jochem mentioned
dys 🐙
dys 🐙2y ago
If you're using npm, they recommend against committing your package-lock.json. If you're using yarn, I think they like you commit yarn.lock. If you're running yarn 2, they actually have you put the yarn executable in the repo. If you're using yarn Plug-n-Play they have you commit your dependencies as well (which yarn manages as a set of zipped tarballs). In general, you're trying to version your sources. If a file is generated from something else, be it node_modules by the package manager, or dist/ by your bundler, you don't put it in the repo.
Want results from more Discord servers?
Add your server