原因分析及解决方法
当我们将 .gitignore 文件配置好后,却往往不能失效。这是因为 .gitignore 只能忽略那些没有被追踪(track)的文件,因为 git 存在本地缓存,如果文件已经纳入了版本管理,那么修改 .gitignore 是不能失效的。那么解决方案就是要将 git 的本地缓存删除,然后重新提交。
- 执行以下Git命令
1 2 3
| git rm -r --cached . git add . git commit -m "update .gitignore"
|
常用的.gitignore文件模板
Spring Boot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| # Created by .ignore support plugin (hsz.mobi) ### JetBrains template # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio *.iml ## Directory-based project format: .idea/ # if you remove the above rule, at least ignore the following: # User-specific stuff: .idea/workspace.xml # .idea/tasks.xml # .idea/dictionaries # Sensitive or high-churn files: # .idea/dataSources.ids # .idea/dataSources.xml # .idea/sqlDataSources.xml # .idea/dynamic.xml # .idea/uiDesigner.xml # Gradle: # .idea/gradle.xml # .idea/libraries *.log *.log.gz
# Mongo Explorer plugin: # .idea/mongoSettings.xml ## File-based project format: *.ipr *.iws ## Plugin-specific files: # IntelliJ /out/ # mpeltonen/sbt-idea plugin .idea_modules/ # JIRA plugin atlassian-ide-plugin.xml # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties ### Maven template target/ pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup pom.xml.next release.properties dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties .DS_Store *.jar
|
Vue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| .DS_Store node_modules/ dist/ npm-debug.log* yarn-debug.log* yarn-error.log* package-lock.json tests/**/coverage/
## build压缩包 dist.tar
# Editor directories and files .idea .vscode *.suo *.ntvs* *.njsproj *.sln
|
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| # Virtual environment bin/ include/ lib/ pyvenv.cfg
.cache *.pyc node_modules yarn-error.log
/public # Build directory /build .DS_Store .sass-cache/ _posts/ _site/
.mypy_cache
/.vscode .idea
|
Spring Cloud
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| ### gradle ### .gradle /build/ !gradle/wrapper/gradle-wrapper.jar
### STS ### .settings/ .apt_generated .classpath .factorypath .project .settings .springBeans bin/
### IntelliJ IDEA ### .idea *.iws *.iml *.ipr rebel.xml
### NetBeans ### nbproject/private/ build/ nbbuild/ nbdist/ .nb-gradle/
### maven ### target/ *.war *.ear *.zip *.tar *.tar.gz *.versionsBackup
### vscode ### .vscode
### logs ### /logs/ *.log
### temp ignore ### *.cache *.diff *.patch *.tmp *.java~ *.properties~ *.xml~
### system ignore ### .DS_Store Thumbs.db Servers .metadata
|