I am making a react project and using Linux mint in Laptop and Windows 10 desktop. I would like to know, which files or folders should I keep in .gitignore so that I don't have to clean cache and install npm whenever I switch computers.
gitignore should contain all files that you want to ignore. Therefore, you should ignore files generated by the OS, the IDE you are working on... My question appears when the repository is on Github and people can clone it and push the changes. These people can use other operating systems and can use other IDEs.
If you use create react app, then a good . gitignore for react projects is included. You definitely want to keep node_modules in gitignore.
Last updated on 3 Apr, 2022. A . gitignore file in project root folder tells Git, what all files to ignore from tracking. Here is a list that can be included in . gitignore file in a normal React project.
You can create a .gitignore file in your repository's root directory to tell Git which files and directories to ignore when you make a commit. To share the ignore rules with other users who clone the repository, commit the .gitignore file in to your repository.
Why bother? Just point your browser to gitignore.io and select all the tools and technologies you are using. You will automatically have a generated .gitignore
file.
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Distribution directories
dist/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
If you use create react app, then a good .gitignore for react projects is included. You definitely want to keep node_modules in gitignore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With