// Set global gitignore file
git config --global core.excludesfile <filename>
Key points
- .gitignore lets you configure Git so that it ignores specific files or files that match a certain pattern.
.html
in your .gitignore matches on all files with an .html extension, in any directory or subdirectory of your project.
/*.html
matches all files with an .html extension, but only in subdirectories of your project.
!
negates a matching rule.
- You can have multiple .gitignore files inside various directories of your project to override higher-level matches in your project.
- You can find where your global .gitignore lives with the command
git config --global core.excludesfile
.
- Make a custom global .gitignore file and use it in all project by
git config —global core.excludesfile <filename>
- GitHub hosts some excellent started .gitignore files at https://github.com/github/gitignore.