最近才發現一個問題,使用Webstorm
新建Node
項目時,是沒有自動生成.gitignore
文件的,所以以前一直把node_modules
和.idea
等無用文件push
到Git
上了,都做那麼多項目了,竟然一直沒發現這個問題,也是對自己無語了?。。。
一般新安裝的WebStorm
是沒有.ignore
這個插件的,所以先要按照下面步驟安裝?
打開setting ? 然後點擊Plugins ? 搜索.ignore ? 第一個安裝install ? 重啓WebStorm
安裝重啓後就可以直接正常使用了?
- 在項目中就會發現可以新建.gitignore文件
- 輸入要忽略的文件,常見格式如下。
.gitignore文件使用實例:
*.a
忽略所有 .a 結尾的文件!lib.a
但 lib.a 除外/TODO
僅僅忽略項目根目錄下的 TODO 文件,不包括 subdir/TODObuild/
忽略 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?