当然,这里提供一个更详细的 .gitignore
模板,这个模板涵盖了多种编程语言和开发工具,你可以根据需要进行调整:
# 忽略编译生成的文件
*.o
*.obj
*.exe
*.dll
*.class
*.jar
*.pyc
__pycache__/
*.pyo
*.pyd
*.node
*.coffee
*.rbc
*.o
*.gch
*.gem
*.lock
*.log
*.db
*.db3
*.sqlite
*.sqlite3
*.sql
*.sqliteo
*.mdb
*.suo
*.nupkg
*.symbols
*.pch
*.vspscc
*.vssscc
*.swp
*~.nib
*.plist
*.a
*.lib
*.so
*.dylib
*.ncb
*.sdf
*.suo
*.pdb
*.idb
*.ilk
*.aps
*.pch
*.vspscc
*.vssscc
*.build
*.pidb
*.sln.docstates
*.user
*.userprefs
*.scc
*.cache
*.log
*.DS_Store
*.bak
*.bak2
*.swp
*.bak0
*.lock
*.tmp
*.temp
*.old
*.orig
*.rej
*.orignal
*.in
*.tmp
*.log
*.zip
*.tar
*.gz
*.rar
*.7z
*.bz2
*.xz
*.exe
*.com
*.scr
*.msi
*.msix
*.msm
*.msp
*.cer
*.pem
*.crt
*.csr
*.key
*.pfx
*.p12
*.p7b
*.p7s
*.bat
*.cmd
*.sh
*.scr
*.sh~
*.py
*.py~
*.pyc
*.pyo
*.pyd
*.pyw
*.py[cod]
*.pdb
*.sln.docstates
*.user
*.userprefs
*.scc
*.cache
*.log
*.ilk
*.aps
*.pch
*.ncb
*.sdf
*.suo
*.nupkg
*.nuspec
*.snk
*.exe
*.dll
*.pdb
*.config
*.csproj
*.sln
*.swp
*.tmp
*.log
*.zip
*.rar
*.gz
*.tar.gz
*.tar.bz2
*.7z
*.bz2
*.xz
*.swp
*~.nib
*.plist
*.dylib
*.ncb
*.sdf
*.suo
*.pdb
*.idb
*.ilk
*.aps
*.pch
*.vspscc
*.vssscc
*.build
*.pidb
*.log
*.vspscc
*.vssscc
*.user
*.userprefs
*.sln.docstates
*.scc
*.cache
*.ilk
*.aps
*.pch
*.ncb
*.sdf
*.suo
*.nupkg
*.nuspec
*.snk
*.exe
*.dll
*.pdb
*.config
*.csproj
*.sln
*.swp
*.tmp
*.log
*.zip
*.rar
*.gz
*.tar.gz
*.tar.bz2
*.7z
*.bz2
*.xz
# 忽略 IDE 配置文件
.idea/
*.iml
*.iws
*.icproj
*.xccheckout
*.xcuserdata
*.xcuserdatadir
*.xcsettings
*.xcworkspace
*.xcworkspacedata
*.xcuserstate
*.xccheckout
*.xcscmblueprint
*.gitignore
*.gitattributes
*.gitmodules
*.git
*.hg
*.svn
*.DS_Store
# 忽略 Node.js 项目文件
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log
yarn.lock
package-lock.json
# 忽略 Java 项目文件
*.class
target/
out/
bin/
build/
.project
.classpath
.settings/
*.iml
*.ipr
*.iws
# 忽略 Python 项目文件
__pycache__/
*.py[cod]
*.pyd
*.pyo
*.pyc
*.pyd
*.pyo
*.dist-info
*.egg-info
*.egg
*.spec
*.dist-info
*.egg-info
*.egg
*.spec
# 忽略 Ruby 项目文件
*.gem
*.gemspec
Gemfile.lock
Rakefile
.ruby-version
.ruby-gemset
.rubyenv
.bundle/
.bundle/config
.bundle/environment.rb
.bundle/bundler/version
.bundle/settings.json
.bundle/cache
.bundle/tmp
vendor/bundle/
vendor/cache/
vendor/cookbooks/
tmp/
*.log
*.pid
*.puma.state
*.pid
*.state
*.swp
*.swo
*.swn
*.swm
*.swx
# 忽略 JavaScript 项目文件
*.log
npm-debug.log
yarn-debug.log
yarn-error.log
yarn.lock
package-lock.json
node_modules/
*.map
*.min.js
*.min.css
*.min.js.map
*.min.css.map
# 忽略 PHP 项目文件
*.log
*.pid
*.state
*.swp
*.swo
*.swn
*.swm
*.swx
vendor/
composer.lock
# 忽略前端构建文件
dist/
build/
*.log
*.pid
*.state
*.swp
*.swo
*.swn
*.swm
*.swx
node_modules/
*.map
*.min.js
*.min.css
*.min.js.map
*.min.css.map
# 忽略数据库文件
*.db
*.sqlite
*.sqlite3
*.sql
*.db3
# 忽略文档和报告文件
doc/
docs/
*.doc
*.docx
*.pdf
*.txt
*.log
*.aux
*.bbl
*.blg
*.log
*.out
*.toc
*.lof
*.lot
*.bak
*.snm
*.nav
*.vrb
*.fls
*fdb_latexmk
*.acn
*.glo
*.ist
*.xdy
*.1
*.2
*.3
*.4
*.5
*.6
*.7
*.8
*.9
*.log
*.ilg
*.toc
*.synctex
*.synctex.gz
*.bbl
*.blg
*.ind
*.lof
*.lot
*.idx
*.nlo
*.aux
*.auxlock
*.out
*.toc
*.fls
*.log
*.fdb_latexmk
*.acn
*.glo
*.ist
*.xdy
*.synctex
*.synctex.gz
*.bbl
*.blg
*.ind
*.lof
*.lot
*.idx
*.nlo
*.bak
*.snm
*.nav
*.vrb
# 忽略测试和构建目录
build/
dist/
out/
*.log
*.pid
*.state
*.swp
*.swo
*.swn
*.swm
*.swx
node_modules/
*.map
*.min.js
*.min.css
*.min.js.map
*.min.css.map
# 忽略其他文件
*~
.*.swp
.*.swo
.*.swn
.*.swm
.*.swx
.*~
Thumbs.db
.DS_Store
这个模板包含了许多常见的文件和文件夹,它们通常不需要被版本控制。您可以根据自己的项目需求,添加或删除某些规则。例如,如果您使用的是 Python,您可能需要添加 *.pyc
到忽略列表中;如果您使用的是 Ruby,您可能需要添加 *.rbc
和 .ruby-version
。