Python 用 .gitignore
Python 用の除外ルール 95 件。そのままリポジトリにコピーして使えます。
Python プログラミング言語
Python 用 .gitignore の完全版
# LFGitignore によって生成 - https://lfgitignore.com
# 作成日:2026-10-31 21:49:06 UTC
# 技術:Python
### Python ###
# Python バイトコード キャッシュ ディレクトリ
__pycache__/
*.py[codz]
# Python/Jython クラス ファイル
*$py.class
# IPython のデフォルト プロファイル
profile_default/
# 共有オブジェクト
*.so
# IPython 構成
ipython_config.py
# Python バージョンマーカー
.Python
# ビルド出力ディレクトリ
build/
# Python の開発用 egg ファイル
develop-eggs/
# 配布ディレクトリ
dist/
# ダウンロードされたファイル
downloads/
# Python の egg パッケージ
eggs/
# Python の egg ディレクトリ
.eggs/
# ライブラリディレクトリ
lib/
# 64ビットライブラリディレクトリ
lib64/
# Buildout のパーツ
parts/
# Pythonソース配布
sdist/
var/
# Python の wheel パッケージ
wheels/
# 共有 Python wheel パッケージ
share/python-wheels/
# Python パッケージのメタデータ
*.egg-info/
# Buildout のインストール済み設定
.installed.cfg
# Python の egg パッケージ
*.egg
# Pythonマニフェストファイル
MANIFEST
# マニフェストファイル
*.manifest
# PyInstaller 仕様ファイル
*.spec
# pip インストールログ
pip-log.txt
# pip のマーカーファイル
pip-delete-this-directory.txt
# カバレッジHTMLレポート
htmlcov/
# tox のテスト環境
.tox/
# noxテスト環境
.nox/
# カバレッジデータファイル
.coverage
# カバレッジデータファイル
.coverage.*
# キャッシュディレクトリ
.cache
# Nose のテスト結果
nosetests.xml
# カバレッジ XML レポート
coverage.xml
# カバレッジの注釈付きソース
*.cover
*.py.cover
# LCOV カバレッジ データ
*.lcov
# Hypothesis のテストデータ
.hypothesis/
# pytestキャッシュディレクトリ
.pytest_cache/
# カバレッジレポート
cover/
# コンパイルされたメッセージ カタログ
*.mo
# メッセージカタログテンプレート
*.pot
# ログファイル
*.log
# ローカルの Django 設定
local_settings.py
# SQLiteデータベース
db.sqlite3
# SQLite ジャーナル
db.sqlite3-journal
# Flask インスタンス フォルダー
instance/
# Flask-Assets のキャッシュ
.webassets-cache
# Scrapy のキャッシュ
.scrapy
# Sphinx ビルドの出力
docs/_build/
# PyBuilder ディレクトリ
.pybuilder/
# Maven ビルド ディレクトリ
target/
# Jupyter ノートブックのチェックポイント
.ipynb_checkpoints
.pdm-python
.pdm-build/
.pixi/*
# PEP 582 パッケージ
__pypackages__/
!.pixi/config.toml
# Celery beat の PID ファイル
celerybeat.pid
# Sage でコンパイルされたファイル
*.sage.py
celerybeat-schedule*
# 環境変数
.env
*.rdb
.envrc
*.aof
# Python仮想環境
.venv
# プロセスIDファイル
*.pid
# 仮想環境ディレクトリ
env/
mnesia/
# 仮想環境ディレクトリ
venv/
rabbitmq/
# 環境バックアップ
env.bak/
rabbitmq-data/
activemq-data/
# 仮想環境のバックアップ
venv.bak/
# Spyder のプロジェクト
.spyderproject
# Spyder プロジェクトの設定
.spyproject
# Python の Rope リファクタリング情報
.ropeproject
/site
# mypy タイプ チェッカー キャッシュ
.mypy_cache/
# mypyデーモンの設定
.dmypy.json
# mypyデーモンの設定
dmypy.json
# Pyre 型チェッカー
.pyre/
# pytype静的アナライザー
.pytype/
# Cython デバッグ シンボル
cython_debug/
.abstra/
.ruff_cache/
.pypirc
marimo/_static/
marimo/_lsp/
__marimo__/
.streamlit/secrets.toml
tempCodeRunnerFile.py
Python のルールで除外されるもの
以下の各パターンと、.gitignore に含める理由を説明します。
バイトコンパイル/最適化/DLLファイル
| パターン |
除外対象 |
__pycache__/ |
Python バイトコード キャッシュ ディレクトリ |
*.py[codz] |
バイトコンパイル/最適化/DLLファイル |
*$py.class |
Python/Jython クラス ファイル |
IPython
| パターン |
除外対象 |
profile_default/ |
IPython のデフォルト プロファイル |
ipython_config.py |
IPython 構成 |
.pdm-python |
pdm Pipfile.lock と同様に、pdm.lock をバージョン管理に含めることが一般的に推奨されます。 pdm では、pdm.toml にプロジェクト全体の構成を含めることを推奨しますが、.pdm-python は除外します。 https://pdm-project.org/en/latest/usage/project/#working-with-version-control pdm.lock pdm.toml |
.pdm-build/ |
IPython |
.pixi/* |
pixi Pipfile.lock と同様に、pixi.lock をバージョン管理に含めることが一般的に推奨されます。 pixi.lock Pixi は、venv モジュールが .venv ディレクトリに仮想環境を作成するのと同じように、.pixi ディレクトリに仮想環境を作成します。このディレクトリをバージョン管理に含めないことをお勧めします。 |
!.pixi/config.toml |
IPython |
配布・パッケージ化
| パターン |
除外対象 |
.Python |
Python バージョンマーカー |
build/ |
ビルド出力ディレクトリ |
develop-eggs/ |
Python の開発用 egg ファイル |
dist/ |
配布ディレクトリ |
downloads/ |
ダウンロードされたファイル |
eggs/ |
Python の egg パッケージ |
.eggs/ |
Python の egg ディレクトリ |
lib/ |
ライブラリディレクトリ |
lib64/ |
64ビットライブラリディレクトリ |
parts/ |
Buildout のパーツ |
sdist/ |
Pythonソース配布 |
var/ |
配布・パッケージ化 |
wheels/ |
Python の wheel パッケージ |
share/python-wheels/ |
共有 Python wheel パッケージ |
*.egg-info/ |
Python パッケージのメタデータ |
.installed.cfg |
Buildout のインストール済み設定 |
*.egg |
Python の egg パッケージ |
MANIFEST |
Pythonマニフェストファイル |
*.manifest |
マニフェストファイル |
*.spec |
PyInstaller 仕様ファイル |
インストーラのログ
| パターン |
除外対象 |
pip-log.txt |
pip インストールログ |
pip-delete-this-directory.txt |
pip のマーカーファイル |
単体テスト/カバレッジレポート
| パターン |
除外対象 |
htmlcov/ |
カバレッジHTMLレポート |
.tox/ |
tox のテスト環境 |
.nox/ |
noxテスト環境 |
.coverage |
カバレッジデータファイル |
.coverage.* |
カバレッジデータファイル |
.cache |
キャッシュディレクトリ |
nosetests.xml |
Nose のテスト結果 |
coverage.xml |
カバレッジ XML レポート |
*.cover |
カバレッジの注釈付きソース |
*.py.cover |
単体テスト/カバレッジレポート |
.hypothesis/ |
Hypothesis のテストデータ |
*.lcov |
LCOV カバレッジ データ |
.pytest_cache/ |
pytestキャッシュディレクトリ |
cover/ |
カバレッジレポート |
翻訳
| パターン |
除外対象 |
*.mo |
コンパイルされたメッセージ カタログ |
*.pot |
メッセージカタログテンプレート |
Django 関連ファイル:
| パターン |
除外対象 |
*.log |
ログファイル |
local_settings.py |
ローカルの Django 設定 |
db.sqlite3 |
SQLiteデータベース |
db.sqlite3-journal |
SQLite ジャーナル |
Flask 関連ファイル:
| パターン |
除外対象 |
instance/ |
Flask インスタンス フォルダー |
.webassets-cache |
Flask-Assets のキャッシュ |
Scrapy 関連ファイル:
| パターン |
除外対象 |
.scrapy |
Scrapy のキャッシュ |
Sphinx のドキュメント
| パターン |
除外対象 |
docs/_build/ |
Sphinx ビルドの出力 |
PyBuilder
| パターン |
除外対象 |
.pybuilder/ |
PyBuilder ディレクトリ |
target/ |
Maven ビルド ディレクトリ |
Jupyter Notebook
| パターン |
除外対象 |
.ipynb_checkpoints |
Jupyter ノートブックのチェックポイント |
PEP 582。github.com/David-OConnor/pyflow や github.com/pdm-project/pdm などで使用されます。
| パターン |
除外対象 |
__pypackages__/ |
PEP 582 パッケージ |
Celery 関連ファイル
| パターン |
除外対象 |
celerybeat.pid |
Celery beat の PID ファイル |
celerybeat-schedule* |
Celery 関連ファイル |
SageMath が解析したファイル
| パターン |
除外対象 |
*.sage.py |
Sage でコンパイルされたファイル |
環境
| パターン |
除外対象 |
.env |
環境変数 |
.envrc |
環境 |
.venv |
Python仮想環境 |
env/ |
仮想環境ディレクトリ |
venv/ |
仮想環境ディレクトリ |
env.bak/ |
環境バックアップ |
venv.bak/ |
仮想環境のバックアップ |
Redis
| パターン |
除外対象 |
*.rdb |
Redis |
*.aof |
Redis |
*.pid |
プロセスIDファイル |
RabbitMQ
| パターン |
除外対象 |
mnesia/ |
RabbitMQ |
rabbitmq/ |
RabbitMQ |
rabbitmq-data/ |
RabbitMQ |
ActiveMQ
| パターン |
除外対象 |
activemq-data/ |
ActiveMQ |
Spyder プロジェクトの設定
| パターン |
除外対象 |
.spyderproject |
Spyder のプロジェクト |
.spyproject |
Spyder プロジェクトの設定 |
Rope のプロジェクト設定
| パターン |
除外対象 |
.ropeproject |
Python の Rope リファクタリング情報 |
/site |
mkdocs ドキュメント |
.mypy_cache/ |
mypy タイプ チェッカー キャッシュ |
.dmypy.json |
mypyデーモンの設定 |
dmypy.json |
mypyデーモンの設定 |
Pyre 型チェッカー
| パターン |
除外対象 |
.pyre/ |
Pyre 型チェッカー |
.pytype/ |
pytype静的アナライザー |
Cython デバッグ シンボル
| パターン |
除外対象 |
cython_debug/ |
Cython デバッグ シンボル |
詳細については、https://abstra.io/docs をご覧ください。
| パターン |
除外対象 |
.abstra/ |
詳細については、https://abstra.io/docs をご覧ください。 |
Ruff 関連ファイル:
| パターン |
除外対象 |
.ruff_cache/ |
Ruff 関連ファイル: |
PyPI設定ファイル
| パターン |
除外対象 |
.pypirc |
PyPI設定ファイル |
Marimo
| パターン |
除外対象 |
marimo/_static/ |
Marimo |
marimo/_lsp/ |
Marimo |
__marimo__/ |
Marimo |
Streamlit
| パターン |
除外対象 |
.streamlit/secrets.toml |
Streamlit |
部分コード実行用の一時ファイル
| パターン |
除外対象 |
tempCodeRunnerFile.py |
部分コード実行用の一時ファイル |
この Python 用 .gitignore の使い方
- 上の Python 用ルールをコピーするか、ファイルを直接ダウンロードしてください。
- Git リポジトリのルートに .gitignore という名前のファイルを作り、ルールを貼り付けます。
- 対象のファイルがすでに追跡されている場合は、git rm -r --cached . を実行して再度コミットしてください。Git の除外ルールは未追跡のファイルにのみ適用されます。
- チーム全員で同じルールを共有できるよう、.gitignore をコミットします。