diff --git a/configs/gitignore/README.md b/configs/gitignore/README.md new file mode 100644 index 0000000..6b9791f --- /dev/null +++ b/configs/gitignore/README.md @@ -0,0 +1,17 @@ +# 常见语言的 .gitignore 配置参考 + +按语言/工具分目录,每个目录一个可直接复制到项目根目录的 `.gitignore`: + +| 目录 | 适用场景 | +| --- | --- | +| `base` | 通用:操作系统、编辑器、日志、压缩包(各语言配置都会引用它) | +| `java` | Maven / Gradle 项目,含 IDE 工程文件(`.idea`、`*.iml`) | +| `dotnet` | .NET 项目(`bin/`、`obj/`、`*.user`) | +| `go` | Go 模块项目(编译产物、覆盖率、`vendor/` 按需启用) | +| `nodejs` | Node.js / 前端项目(`node_modules/`、构建产物、日志) | +| `python` | Python 项目(`__pycache__/`、虚拟环境、测试与打包缓存) | + +各文件内容取自 GitHub 官方 `github/gitignore` 模板并做了精简,保持了与 `configs/dockerignore` 一致的目录结构: +需要哪种语言就复制对应目录的 `.gitignore`,跨语言的项目可把多个文件内容合并到项目根目录的 `.gitignore`。 + +> 说明:仓库根目录自己的 `.gitignore` 已经存在,不要把这里的文件直接覆盖过去,按需合并即可。 diff --git a/configs/gitignore/base/.gitignore b/configs/gitignore/base/.gitignore new file mode 100644 index 0000000..9932c5e --- /dev/null +++ b/configs/gitignore/base/.gitignore @@ -0,0 +1,23 @@ +# ---- 操作系统 ---- +.DS_Store +._* +.Spotlight-V100 +.Trashes +Thumbs.db +ehthumbs.db +Desktop.ini + +# ---- 编辑器 / IDE ---- +.vscode/ +.idea/ +*.swp +*.swo +*~ +.tags + +# ---- 日志与临时文件 ---- +*.log +logs/ +tmp/ +*.tmp +*.bak diff --git a/configs/gitignore/dotnet/.gitignore b/configs/gitignore/dotnet/.gitignore new file mode 100644 index 0000000..62c49e1 --- /dev/null +++ b/configs/gitignore/dotnet/.gitignore @@ -0,0 +1,42 @@ +# ---- 编译输出 ---- +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ +*.dll +*.exe +*.pdb +*.cache + +# ---- 构建工具 ---- +artifacts/ +.vs/ +*.user +*.suo +*.userosscache +*.sln.docstates +*.rsuser + +# ---- 调试 / 测试 ---- +*.[Cc]ache +TestResults/ +*.trx +coverage*.json +coverage*.xml +coverage*.info +*.coverage +*.coveragexml + +# ---- 发布 / NuGet ---- +publish/ +*.nupkg +*.snupkg +.nuget/ +packages/ +project.lock.json + +# ---- ReSharper / Rider ---- +_ReSharper*/ +*.DotSettings.user +.idea/ diff --git a/configs/gitignore/go/.gitignore b/configs/gitignore/go/.gitignore new file mode 100644 index 0000000..bcd7687 --- /dev/null +++ b/configs/gitignore/go/.gitignore @@ -0,0 +1,26 @@ +# ---- 编译产物 ---- +*.exe +*.exe~ +*.dll +*.so +*.dylib +*.test +*.out +bin/ +dist/ + +# ---- 测试与覆盖率 ---- +coverage.out +coverage.html +*.coverprofile +profile.cov + +# ---- Go 工作区 / 模块缓存 ---- +go.work +go.work.sum +vendor/ + +# ---- 工具 ---- +.golangci.yml +.tool-versions +# go.sum 与 go.mod 应当提交,不要忽略 diff --git a/configs/gitignore/java/.gitignore b/configs/gitignore/java/.gitignore new file mode 100644 index 0000000..a484b7a --- /dev/null +++ b/configs/gitignore/java/.gitignore @@ -0,0 +1,43 @@ +# ---- 编译产物 ---- +target/ +build/ +out/ +bin/ +*.class +*.jar +*.war +*.ear +*.log + +# ---- Maven ---- +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties +dependency-reduced-pom.xml + +# ---- Gradle ---- +.gradle/ +!gradle/wrapper/gradle-wrapper.jar +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +# ---- IDE ---- +.idea/ +*.iml +*.ipr +*.iws +.settings/ +.classpath +.project +.apt_generated +*.launch +.factorypath + +# ---- 其它 ---- +hs_err_pid* +replay_pid* +*.hprof diff --git a/configs/gitignore/nodejs/.gitignore b/configs/gitignore/nodejs/.gitignore new file mode 100644 index 0000000..3888d85 --- /dev/null +++ b/configs/gitignore/nodejs/.gitignore @@ -0,0 +1,39 @@ +# ---- 依赖 ---- +node_modules/ +jspm_packages/ +bower_components/ +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# ---- 日志 ---- +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +# ---- 构建产物 ---- +dist/ +build/ +.output/ +.next/ +.nuxt/ +.cache/ +.parcel-cache/ +.eslintcache +coverage/ +*.tsbuildinfo + +# ---- 环境变量 ---- +.env +.env.* +!.env.example + +# ---- 其它 ---- +.npm +.pnpm-store/ +*.tgz diff --git a/configs/gitignore/python/.gitignore b/configs/gitignore/python/.gitignore new file mode 100644 index 0000000..3d43c06 --- /dev/null +++ b/configs/gitignore/python/.gitignore @@ -0,0 +1,50 @@ +# ---- 字节码 / 缓存 ---- +__pycache__/ +*.py[cod] +*$py.class +*.so +.python + +# ---- 打包 / 构建 ---- +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# ---- 虚拟环境 ---- +.venv/ +venv/ +env/ +ENV/ +.env +.env.* +!.env.example + +# ---- 测试与类型检查缓存 ---- +.pytest_cache/ +.coverage +.coverage.* +htmlcov/ +.tox/ +.nox/ +.hypothesis/ +.mypy_cache/ +.dmypy.json +.ruff_cache/ +.pytype/ + +# ---- PyInstaller / Jupyter ---- +*.manifest +*.spec +.ipynb_checkpoints/