[英]How to add a folder to the .gitignore
也許我缺乏谷歌搜索技能,但這似乎是一個應該給我帶來數千次點擊的問題,然而,我找不到直接的答案。
就這么簡單:
我不斷推送到 github 以與遠程開發人員共享。 我們都安裝了npm
和bower
。 無需一直將這些龐大的文件夾推送到 github。 我的node_modules
被忽略。 但我似乎無法讓gitignore
忽略我的bower_components
文件夾
我對 cmd 不太了解,我幾乎沒有觸及表面,所以如果你打算建議,請不要假設我知道你在說什么。 否則,如果它像使用 IDE 將它添加到文件本身一樣簡單,那么,我做到了,沒有雪茄。 這是我的 .gtignore 文件供您查看
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing- task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
bower_components
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
我錯過了什么嗎? 如何使 bower_components 被忽略?
謝謝
如果你想忽略文件夾,你需要一個斜杠:
bower_components/
然后使用git check-ignore -v
規則是否適用(如果您想查看導致文件被忽略的確切.gitignore
文件和行, -v
很重要)
git check-ignore -v -- bower_components/afile
如果這不適用,則從該存儲庫的歷史記錄中刪除該文件夾的內容:
git rm --cached -r -- bower_components/
git add .
git commit -m "Remove bower_components folder"
然后.gitignore
規則將立即生效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.