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文件忽略指定文件

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