Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between .npmignore and .gitignore?

What's the difference between .npmignore and .gitignore? What kind of files should I ignore in each?

like image 997
Yangshun Tay Avatar asked May 03 '17 16:05

Yangshun Tay


People also ask

What is a Gitignore used for?

gitignore file tells Git which files to ignore when committing your project to the GitHub repository. gitignore is located in the root directory of your repo. / will ignore directories with the name.

When should I use Gitignore?

When Do You Use Git Ignore File? The git ignore file rule allows you to ignore a file you've committed in the past. You use it when you do not want to recommit a file, for example a build artifact.

Does npm ignore Gitignore?

gitignore file, then npm will ignore the stuff matched by the . gitignore file. If you want to include something that is excluded by your . gitignore file, you can create an empty .

Is Gitignore necessary?

Using a . gitignore file is a best practice for improving the quality of your code and Git repositories. I have noticed that many developers do not use a . gitignore file, even though it's a best practice to use one to designate files you don't want Git to track in version control.


2 Answers

.gitignore lists which files & folders should be omitted from any commits to the repository. You can use this repo for templates of files/folders to in your .gitignore depending on your environment.

.npmignore works similarly to .gitignore, it is used to specify which files should be omitted when publishing the package to NPM. You can read more about it in the .npmignore docs

like image 187
peteb Avatar answered Oct 05 '22 20:10

peteb


Use a .npmignore file to keep stuff out of your package. If there's no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file. If you want to include something that is excluded by your .gitignore file, you can create an empty .npmignore file to override it.

like image 38
12345678 Avatar answered Oct 05 '22 21:10

12345678