WebStorm新建Node项目利用.gitignore文件忽略指定文件

最近才发现一个问题,使用Webstorm新建Node项目时,是没有自动生成.gitignore文件的,所以以前一直把node_modules.idea等无用文件pushGit上了,都做那么多项目了,竟然一直没发现这个问题,也是对自己无语了?。。。

一般新安装的WebStorm是没有.ignore这个插件的,所以先要按照下面步骤安装?

打开setting ? 然后点击Plugins ? 搜索.ignore ? 第一个安装install ? 重启WebStorm

安装重启后就可以直接正常使用了?

  1. 在项目中就会发现可以新建.gitignore文件
  2. 输入要忽略的文件,常见格式如下。

.gitignore文件使用实例:

  • *.a 忽略所有 .a 结尾的文件
  • !lib.a 但 lib.a 除外
  • /TODO 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
  • build/ 忽略 build/ 目录下的所有文件
  • doc/*.txt 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

Node项目中.gitignore的常见配置:

# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/
.idea/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# 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

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

.idea/

Over?


自建博客地址:ahuiyo的博客 - WebStorm新建Node项目利用.gitignore文件忽略指定文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章