Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which files or folders should be in .gitignore in React project?

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.

like image 848
SAIF AHMED ANIK Avatar asked Feb 14 '20 06:02

SAIF AHMED ANIK


People also ask

What files should be in Gitignore?

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.

Should I Gitignore build folder React?

If you use create react app, then a good . gitignore for react projects is included. You definitely want to keep node_modules in gitignore.

What is Gitignore file in React?

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.

Where should I create .gitignore file?

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.


3 Answers

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.

like image 94
Prashant Avatar answered Oct 23 '22 19:10

Prashant


# 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
like image 7
Hamid Shoja Avatar answered Oct 23 '22 18:10

Hamid Shoja


If you use create react app, then a good .gitignore for react projects is included. You definitely want to keep node_modules in gitignore.

like image 3
Christian Fosli Avatar answered Oct 23 '22 20:10

Christian Fosli